name amont id jhon 2000 1 neo 3000 2 jhon 1000 1 neo 2000 2
name id jhon 1 neo 2 rams 3 raj 4 anna 5
select table1.name,sum(amount),table2.id from table1,table2 group by table2.id
jhon 8000 1 neo 8000 2 rams 8000 3 raj 8000 4 anna 8000 5
jhon 3000 neeo 5000 rams 0 raj 0 anna 0
SELECT table1.name, IF( isnull( sum( amount ) ) , 0, sum( amount ) ) , table2.id FROM table1 RIGHT JOIN table2 ON table1.id = table2.id GROUP BY table2.id
SELECT tb1.name,SUM(CASE WHEN tb1.id=tb2.id THEN amount ELSE 0 END) AS "Total" FROM t1 AS tb1, t2 AS tb2 GROUP BY tb1.name
select TABLE2.id, isnull( Sum(amount),0) from TABLE2 LEFT outer join table1 on TABLE2.ID = TABLE1.ID group by TABLE2.ID
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)