sql - MYSQL: Select sum values from one column into multiple columns grouped by values selected from second table -
i have 2 tables
table 'earning':
id | amount | date | currency_id ----------------------------- 0 | 100000 | 01-01-2015 | 0 1 | 200000 | 01-01-2015 | 1 2 | 300000 | 01-01-2015 | 0 3 | 400000 | 02-01-2015 | 1 4 | 500000 | 02-01-2015 | 1
table 'currencies':
id | code --------- 0 | usd 1 | eur
so have possibility add new currency @ time.
is possible select both tables following result?
date | earned_usd | earned_eur ------------------------------------- 01-01-2015 | 400000 | 200000 02-01-2015 | 0 | 900000
thank lot!
Comments
Post a Comment