Message-Id: <10482.104512@fatcity.com> From: "Michael Sun" Date: Sun, 30 Apr 2000 00:21:23 -0400 Subject: Re: who is the 500000th user This is a multi-part message in MIME format. ------=_NextPart_000_0220_01BFB23A.04509360 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable ROWNUM is a function applied only to the recordset (query results), not = to the=20 table itself. So the following query will get the max(user_id) on the table, select = all records from the table, then limit the output to the first 500000 rows, and give you a count. > SQL> select count(*) , max(user_id) from userbasicinfo where = rownum<500001; >=20 While the next query will count all users in this table (because user_id = clause uses the=20 maximum value). >=20 > SQL> select count(*) from userbasicinfo where user_id<=3D524351; ------=_NextPart_000_0220_01BFB23A.04509360 Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable
ROWNUM is a function applied = only to the=20 recordset (query results), not to the
table = itself.

So the following query will = get the=20 max(user_id) on the table, select all records from the=20 table,
then limit the output to the = first 500000=20 rows, and give you a count.
 
> SQL> select count(*) , = max(user_id) from=20 userbasicinfo where rownum<500001;
>
While the next query will count = all users=20 in this table (because user_id clause uses the
maximum = value).
>
> SQL> select count(*) = from=20 userbasicinfo where = user_id<=3D524351;