SELECT KodeRek, " & _
"SUM(CASE WHEN MONTH(TGL) = 1 THEN TRANSAKSI ELSE 0 END) AS JAN, SUM(CASE WHEN MONTH(TGL) = 2 THEN TRANSAKSI ELSE 0 END) AS FEB, " & _
"SUM(CASE WHEN MONTH(TGL) = 3 THEN TRANSAKSI ELSE 0 END) AS MAR, SUM(CASE WHEN MONTH(TGL) = 4 THEN TRANSAKSI ELSE 0 END) AS APR, " & _
"SUM(CASE WHEN MONTH(TGL) = 5 THEN TRANSAKSI ELSE 0 END) AS MAY, SUM(CASE WHEN MONTH(TGL) = 6 THEN TRANSAKSI ELSE 0 END) AS JUN, " & _
"SUM(CASE WHEN MONTH(TGL) = 7 THEN TRANSAKSI ELSE 0 END) AS JUL, SUM(CASE WHEN MONTH(TGL) = 8 THEN TRANSAKSI ELSE 0 END) AS AUG, " & _
"SUM(CASE WHEN MONTH(TGL) = 9 THEN TRANSAKSI ELSE 0 END) AS SEP, SUM(CASE WHEN MONTH(TGL) = 10 THEN TRANSAKSI ELSE 0 END) AS OCT, " & _
"SUM(CASE WHEN MONTH(TGL) = 11 THEN TRANSAKSI ELSE 0 END) AS NOV, SUM(CASE WHEN MONTH(TGL) = 12 THEN TRANSAKSI ELSE 0 END) AS DEC " & _
"FROM V_JURNAL WHERE YEAR(TGL)=" & cmbTahun.Text & "" & _
"GROUP BY KodeRek"
Monday, February 17, 2014
SQL Crosstab Query by Month
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment