Postingan lainnya
cara join 2 table
permisi agan2 mau tanya cara join 2 table terus nampilin semua data di table pertama meskipun di table kedua itu datanya kosong gimana ya? nih kodingan saya
SELECT
`tb_account`.`AccNo`,
`tb_account`.`AccName`,
SUM(tb_transd.debit) AS debit,
SUM(tb_transd.kredit) AS kredit,
IF (SUM(tb_transd.debit - tb_transd.kredit) >= 0,SUM(tb_transd.debit - tb_transd.kredit),0) AS saldo_debit,
IF (SUM(tb_transd.debit - tb_transd.kredit) <= 0,SUM(tb_transd.kredit - tb_transd.debit),0) AS saldo_kredit
FROM `tb_account`
LEFT OUTER JOIN `tb_transd` ON `tb_transd`.`AccNo` = `tb_account`.`AccNo`
WHERE YEAR (tb_transd.date) = '2017' AND MONTH (tb_transd.date) = '3'
GROUP BY `tb_account`.`AccNo`
ORDER BY `tb_account`.`AccNo` ASC
0
Belum ada Jawaban. Jadi yang pertama Jawaban
Login untuk ikut Jawaban