im doing a project for learning, and having some question that i need to answer with comparing the data between years 2009 and 2010.
it just containt 1 table with table name data_penjualan
the current query that i write is just can show both of year in vertical.. so its show 2009 first and below it has the 2010 data. is there possible to make the data in vertical like Years | Product_sub_Category|sales 2009 | Sales 2010
select
extract(year from order_date) as years,
product_sub_category,
sum(sales) as sales
from data_penjualan
where extract(year from order_date) IN ('2009', '2010') and order_status = "Order Finished"
group by 1,2
order by 1,3 DESC;
this is the picture, sorry for bad english
CodePudding user response:
The solution for your query could be similar to one of the answer in this post.