I have to submit the orderdata group by month and card type during the year as follows:
MONTH CARDTYPE ORDER_CNT 201201 AMEX 10,835 201201 DISC 6,542 201201 MC 2,675 201202 AMEX 66,817 201202 DISC 36,581 201202 MC 165,683
The table from which I can get the data has orders for each day of the month. I used the following SQL to group the number of orders for each day of the month by card type:
(
SELECT cardtype,orderdate,COUNT (distinct(orderserialno)) FROM tablename where orderdate between '01-jan-2012' and '31-dec-2012' GROUP BY cardtype,orderdate
)
Now I need to present this data in the form above using the case argument, since I have to group it by month, however I cannot do this. Maybe someone can help.
thanks
sql oracle
user2356581
source share