>Table User >UserID UserName >0001 John >0002 Jones >0003 PDRM > >TableSales >UserID SalesAmt InvoiseNo >0001 1000 00001 >0001 2000 00002 >0002 500 00003 > >TableTopup >UserID TopupAmt TranNo >0001 1000 000001 >0002 1100 000002 > >Expected Result >UserID: 0001 >UserName: John > SalesAmt 3000 (SUM) > TopupAmt 1000 (SUM) > >UserID: 0002 >UserName: Jones > SalesAmt 500 (SUM) > TopupAmt 1100 (SUM) > >>Seem there are not any transaction involve User 0003, therefore, it should not be displayed.
select a.userid, a.username, sum(b.SalesAmt), sum(c.TopupAmt) ; from tableA a ; inner join tableB b on a.userid = b.userid ; inner join tableC c on b.userid = c.userid ; group by 1Cetin