Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Getting limited number of rows on a table

Getting limited number of rows on a table

From: avaneesh.arora <avaneesh.arora_at_mci2000.com>
Date: 1998/06/13
Message-ID: <2dmg1.234$HY5.230636@pm01nn>#1/1

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 Received on Sat Jun 13 1998 - 00:00:00 CDT

Original text of this message

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