Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Help needed for select query
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