Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE sales (
- id int,
- currency VARCHAR(5),
- price int
- shop_id int
- );
- SELECT shop_id, (CASE WHEN currency= "GBP" THEN SUM(price) ELSE 0 END) AS POUND , (CASE WHEN currency= "USD" THEN SUM(price) ELSE 0 END) AS USDOLLAR GROUP BY shop_id, currency
- _________________________________________
- shop_id | POUND | USDOLLAR |
- -----------------------------------------
- 1 | 400 | 300 |
- -----------------------------------------
- 2 | 250 | 100 |
- -----------------------------------------
- 3 | 400 | 100 |
- -----------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement