mysql - How to calculate from 2 tables in SQL -
how create query join table , b condition a.salary * b.rate
table --------------------- customerid salary a1 100 a2 200 a3 300 table b --------------------- customerid rate a1 2 a2 3 a3 4
my expect result.
--------------------- customerid salary a1 200 a2 600 a3 1200
select t1.customerid, coalesce(t1.salary * t2.rate, 'na') salary tablea t1 left join tableb t2 on t1.customerid = t2.customerid
i used coalesce
when computing effective salaries in case either salary amount or rate null
customer.
demo here:
Comments
Post a Comment