With the above sql,let say I have another table which is table2, the relation key is table1.vl and table2.vl. Table2 has amount field and I need to get the value of amount field.
select GUNAG,MSS,KBB,sum(LKK) as SALE from table1
where BANDT = 'dtdt'
group by GUNAG,MSS,KBB
I tried with this below, I think this will not work. How should I write the query?
select table2.amount,table1.GUNAG,table1.MSS,table1.KBB,sum(table1.LKK) as SALE from table1
join table2 on table1.vl=table2.vl
where table1.BANDT = 'dtdt'
group by table1.GUNAG,table1.MSS,table1.KBB