Pivot Table & Order by to_char date?
DorbsApr 30 2013 — edited Apr 30 2013Hi,
I need to show the results of my sql query in a pivot table.
This is the query currently -
select to_char(create_date_time,'Month'), Carrier, count(order_nbr)sum (total_Qty) from wm_archive.outpt_carton_hdr@awm.corp.cjclark.com
where to_char(create_date_time,'YYYY') = '2012'
group by Carrier, to_char(create_date_time,'Month')
At the moment this brings back over 130 rows and 3 columns - Month, count(order_nbr) and sum(total_qty).
Ideally i'd like to put this into a pivot table where I have just 12 rows - all the months, and the number of columns would depend on the amount of carriers there are, so it'd be something like -
Month Carrier_1_orders Carrier_1_total_Qty Carrier_2_orders Carrier_2_total_Qty
Is this possible? Would case statements help me achieve this?
Thanks a lot for your help (any appreciated!)