Re: Many aggregates in one query

From: Mikito Harakiri <nospam_at_newsranger.com>
Date: Tue, 21 Aug 2001 05:06:04 GMT
Message-ID: <0%lg7.8739$2u.62742_at_www.newsranger.com>


In article <9ls5nh$kfc$1_at_stlnews.stl.ibm.com>, Aakash Bordia says...
>
>Well it depends. rownum might not be the standard...rownumber() is. Is
>rownum available in Oracle?

Yes, but I'm not aware of rownumber()...

Well, working with row numbers is nonrelational hack anyway.

>Thanks
>Aakash
>"Mikito Harakiri" <nospam_at_newsranger.com> wrote in message
>news:Tcif7.5590$2u.54105_at_www.newsranger.com...
>> In article <9lk0u0$g70$1_at_stlnews.stl.ibm.com>, Aakash Bordia says...
>> >
>> >How about
>> >SELECT col1,COUNT(*) FROM IN1 group by col1 order by count(*),col1 fetch
>> >first 1 rows only
>>
>> Right. Except that "fetch first 1 rows only" can be transformed into
 something
>> more legitimate like
>>
>> select * from( select *, rownum rn from inner_query) where rn < 2
>>
>> The query becomes:
>>
>> select minnum, rowcnt from (
>> select minnum, rowcnt, rownum rn from (
>> select id, count(1) rowcnt from test group by id order by rowcnt, id
>> )
>> ) where rn < 2
>>
>>
>>
>
>
Received on Tue Aug 21 2001 - 07:06:04 CEST

Original text of this message