I would like pivot using sql query below would be my data format:
| Date | Sales | Count |
|---|---|---|
| 07-May | Coffee | 20 |
| 07-May | Tea | 50 |
| 07-May | Chia | 30 |
| 14-May | Tea | 40 |
| 14-May | Coffee | 60 |
I would like my data to be output using oracle sql query to be in the below format:
| Sale | 07-May | 14-May |
|---|---|---|
| Coffee | 20 | 60 |
| Chia | 30 | |
| Tea | 50 | 40 |
Could you please assist over here?
you can use pivot like this:
SELECT * FROM
(
SELECT Date,Sales,Count
FROM your_table
)
PIVOT
(
sum(Count)
FOR Date IN ('07-May', '14-May')
) ;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With