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:27:29 GMT
Message-ID: <3bdafa0f.1477485@news.easynet.co.uk>


On Fri, 26 Oct 2001 15:16:27 +0200, "andrija" <ar35644_at_fer.hr> wrote:

>Try something like this:
>
>select A.source, A."Yesterday",B."Last week"
>from
>(SELECT source, COUNT(*) as "Yesterday"
>FROM event
>WHERE time > TRUNC(SYSDATE-1)
>GROUP BY source
>ORDER BY COUNT(*) DESC, source) A,
>(SELECT source, COUNT(*) "Last week"
>FROM event
>WHERE time > TRUNC(SYSDATE-7)
>GROUP BY source
>ORDER BY COUNT(*) DESC, source) B
>where A.source=B.source
>order by 2 desc,1

Thank you, Andrija

It works well although I do not know how it works :-)

I think it is also expandable by the insertion of more lines, for example:

...C."The last three days" ....
...WHERE time > TRUNC(SYSDATE-3)...
...WHERE A.source=B.source AND A.source=C.source...

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

Original text of this message

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