Re: Need Help with PL/SQL

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: 1996/10/23
Message-ID: <326d9737.9779201_at_dcsun4>#1/1


On Wed, 23 Oct 1996 09:56:17 -0400, "Kevin S. DeWitt" <dewitt_at_interramp.com> wrote:

>Thomas J. Kyte wrote:
>>
>> In 7.1 and up you can simply:
>>
>> select *
>> from (
>> SELECT EO_SHIPPED.SHIP_DATE, COUNT(EO_SHIPPED.ORDERNUM) CNT
>> FROM WHISC.EO_SHIPPED EO_SHIPPED
>> WHERE (EO_SHIPPED.SHIP_DATE
>>=ADD_MONTHS(SYSDATE,-5))
>> AND (TO_CHAR(EO_SHIPPED.SHIP_DATE,'DAY') NOT LIKE 'S%')
>> GROUP BY SHIP_DATE )
>> where rownum <= 100
>>
>
>Thomas,
>
>Will your solution work if there is an ORDER BY
>involved? My understanding of rownum is that it is
>derived prior to the sort.
>
>

Correct, you can't use rownum and order by at the same time. You can use group by and rownum together in the above fashion tho. The rownum will be evaluated AFTER the group by has taken place.

>
>
>Thanks,
>Kevin DeWitt
>Pgh, PA

Thomas Kyte
Oracle Government
tkyte_at_us.oracle.com                          

http://govt.us.oracle.com

  • Check out Oracle Governments web site! ----- Follow the link to "Tech Center" and then downloadable Utilities for some free software...

statements and opinions are mine and do not necessarily reflect the opinions of Oracle Corporation Received on Wed Oct 23 1996 - 00:00:00 CEST

Original text of this message