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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Help needed for select query

Re: Help needed for select query

From: <library.treasures_at_NOSPAMsaqnet.co.uk>
Date: Sat, 27 Oct 2001 18:42:29 GMT
Message-ID: <3bdaff90.2887390@news.easynet.co.uk>


On Fri, 26 Oct 2001 13:43:48 GMT,
SPAMBLOCK.Maxwell_Smart_at_ThePentagon.com.SPAMBLOCK (Brian Tkatch) wrote:

>On Fri, 26 Oct 2001 12:53:38 GMT, library.treasures_at_NOSPAMsaqnet.co.uk
>wrote:
>
>>I have an event table with a source column and a time colum.
>>
>>I need to count and sort in descending order the number of events per
>>source.
>>
>>I can count one day's totals and the last week's totals by two
>>separate scripts:
>>
>>SELECT source, COUNT(*) "Yesterday"
>>FROM event
>>WHERE time > TRUNC(SYSDATE-1)
>>GROUP BY source
>>ORDER BY COUNT(*) DESC, source;
>>
>>SELECT source, COUNT(*) "Last week"
>>FROM event
>>WHERE time > TRUNC(SYSDATE-7)
>>GROUP BY source
>>ORDER BY COUNT(*) DESC, source;
>>
>>
>>However, I would like to unify these two separate queries in a single
>>query because I want the two column, "Yesterday" and "Last week", to
>>appear side by side.
>>
>>How is it possible to achieve this?
>>
>>Thanks for any help in advance.
>>
>>Thomas
>
>
>The easiest way to put any columns side by side would be to encase
>them in another query. As long as they each only return one row.
>
>SELECT (Query_1), (Query_2) FROM Dual;
>
>Brian

Many thanks indeed, Brian

This will come useful, too.

I am only learning, but there are so many tricks...

Regards,
Thomas Received on Sat Oct 27 2001 - 13:42:29 CDT

Original text of this message

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