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: Getting limited number of rows on a table

Re: Getting limited number of rows on a table

From: <kalpha5_at_my-dejanews.com>
Date: 1998/06/15
Message-ID: <6m3pis$3uu$1@nnrp1.dejanews.com>#1/1

Try this

            1  select aa1.accessid, aa1.alarmindex, aa1.alarmseqnum
            2  FROM ALARM_TABLE  aa1
            3  where rownum <= 10;

In article <2dmg1.234$HY5.230636_at_pm01nn>,   "avaneesh.arora" <avaneesh.arora_at_mci2000.com> wrote:
>
> Hi All,
>
> Thanks for your replies.
>
> However, for some reason, the query does not seem to be working correctly
> for
> my table with a primary key consisting of 3 columns.
>
> This is what I have :
>
> 1 select aa1.accessid, aa1.alarmindex, aa1.alarmseqnum
> 2* FROM ALARM_TABLE aa1
>
> ACCESSID ALARMINDEX ALARMSEQNUM
> ------------ ---------------- -----------
> 100 2 1
> 100 3 2
> 100 2 3
> 100 2 4
> 4 2 5
> 4 3 6
> 5 2 7
> 5 2 8
> 105 2 9
> 105 3 10
> 105 2 11
> 105 2 12
> 103 2 13
> 103 2 14
>
> 14 rows selected.
>
> 1 select aa1.accessid, aa1.alarmindex, aa1.alarmseqnum
> 2 FROM ALARM_TABLE aa1
> 3 where 10 > (select count(*) from ALARM_TABLE aa2
> 4 where aa2.accessid <= aa1.accessid
> 5 and aa2.alarmindex <= aa1.alarmindex
> 6 and aa2.alarmseqnum <= aa1.alarmseqnum)
> 7* order by aa1.accessid asc, aa1.alarmindex asc, aa1.alarmseqnum asc
>
> ACCESSID ALARMINDEX ALARMSEQNUM
> ------------ ---------------- -----------
> 4 2 5
> 4 3 6
> 5 2 7
> 5 2 8
> 100 2 1
> 100 2 3
> 100 2 4
> 100 3 2
> 103 2 13
> 103 2 14
> 105 2 9
> 105 2 11
> 105 2 12
>
> 13 rows selected.
>
> Why do I get 13 rows when I am limiting the number to 10 only ?
> Also how do I get next 10 (or previous 10 at a later point) ?
>
> Any solutions will be appreciated.
>
> Thanks,
> Avaneesh
>
>

-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/ Now offering spam-free web-based newsreading Received on Mon Jun 15 1998 - 00:00:00 CDT

Original text of this message

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