Tuesday, April 01, 2014

SQL - To get return null value when selection no match

SELECT     TOP (100) PERCENT dbo.V_PERKIRAAN.KodeRek, ISNULL(SUM(dbo.V_JURNAL.TRANSAKSI), 0) AS SALDOAWAL
FROM         dbo.V_PERKIRAAN LEFT OUTER JOIN
                      dbo.V_JURNAL ON dbo.V_PERKIRAAN.KodeRek = dbo.V_JURNAL.KodeRek AND dbo.V_JURNAL.Tgl <= '2014-01-01' AND YEAR(dbo.V_JURNAL.Tgl) = '2014'
GROUP BY dbo.V_PERKIRAAN.KodeRek
ORDER BY dbo.V_PERKIRAAN.KodeRek