Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Simple ( I hope) SQL needed

Re: Simple ( I hope) SQL needed

From: don hunt <dohunt_at_hotmail.com>
Date: 17 Sep 2001 16:43:28 -0700
Message-ID: <1b56e975.0109171543.83e2e87@posting.google.com>


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

Group By to_char(datea,'Mon'), ItemNo; Received on Mon Sep 17 2001 - 18:43:28 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US