Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Simple ( I hope) SQL needed
rsanjaynj_at_yahoo.com (Sanjay Raj) wrote in message news:<9f767483.0109171055.5a0abcc3_at_posting.google.com>...
> I have table containing dates and order details
> Desc Order
> OrderID,
> ItemNo,
> Date,
> quantity,
> total
>
> The same order placed on the same day can have more than one item. I
> want a simple SQL query which will give me the number of orders of
> each item placed month wise. The date in the ORDER table is individual
> dates such as 01-JAN-01, 31-JAN-01, 05-MAR-01 etc. I want to know how
> may orders were placed by month. Say something like
>
> Month ItemNo Number of Orders Quantity
> Jan 123 10 100
> Jan 321 5 300
> Feb 123 2 80
> ....
> ...
>
> Thanks for the help
Since Order and Date are reserved words in Oracle, you shouldn't use them as table/column names. If you do, replace my names with yours in ""
Select to_char(datea,'Mon') "Month", ItemNo, count(*)"Number of Orders",
sum(Quantity) "Quantity" from Ordera