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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Need query to group by date

Re: Need query to group by date

From: Bob McConnell <bob.mcconnell_at_mci.com>
Date: Thu, 14 Sep 2000 16:18:45 GMT
Message-ID: <39C0FA13.D455B4C5@mci.com>

Thanks, but that doesn't give me what I'm looking for. I need the results to look like this:
ORDERSTATUS 30 30-60 60-90 >90

Canceled                3        5          2        7
Complete               50     125         76     345
INPROCESS          45       23         98     567
etc.

Bob

OasisFan wrote:

> Bob McConnell napisa³(a) w wiadomoœci: <39BFE46F.D6FAEBE1_at_mci.com>...
> >I have a table of ORDERS which has an OrderDate field and an OrderStatus
> >field. I would like to query to get orders <30 days, 30 to 60days, 60
> >to 90days and > 90 grouped by Orderstatus. How would I do that?
> >
> >thanks
> >Bob
> >
>
> Try UNION operator...
>
> Select orderstatus, count(*)
> from XXX
> where orderdate < 30 days
> group by orderstatus
> UNION
> Select orderstatus, count(*)
> from XXX
> where 30 days < orderdate < 60 days
> group by orderstatus
> UNION
> Select orderstatus, count(*)
> from XXX
> where orderdate > 60 days
> group by orderstatus;
>
> (sorry for syntax..its not quite correct).
> buy it may help.
Received on Thu Sep 14 2000 - 11:18:45 CDT

Original text of this message

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