Received: from despair.sowrong.org (syr-24-24-23-149.twcny.rr.com [24.24.23.149]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f4BExiA12261 for ; Fri, 11 May 2001 10:59:44 -0400 (EDT) (envelope-from cjc26@despair.sowrong.org) Received: (from cjc26@localhost) by despair.sowrong.org (8.11.0/8.11.0) id f4BF1Aq26164; Fri, 11 May 2001 11:01:10 -0400 (EDT) Date: Fri, 11 May 2001 11:01:10 -0400 From: Cliff Crawford To: Robert Beer Cc: "'pgsql-sql@postgresql.org'" Subject: Re: Newbie ex-Oracle person's question: Oracle ROWID = PSQL OID, Orac le ROWNUM = PSQL ??? Message-ID: <20010511110110.B26098@cornell.edu> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from Robert.Beer@Callserve.com on Tue, May 08, 2001 at 04:01:33PM -0000 X-Archive-Number: 200105/95 X-Sequence-Number: 2904 * Robert Beer menulis: > Oracle has a ROWNUM pseudo column that works like this ... > TEST>select callid, rownum from cs_calls where rownum < 5; > > CALLID ROWNUM > ---------- ---------- > 7806 1 > 7807 2 > 7809 3 > 6443 4 > > 4 rows selected. > > ... which can be quite handy. > > Is there something like this in PSQL? You can use the LIMIT clause: SELECT callid FROM cs_calls LIMIT 4; See for more info. > By the way, having used Oracle since 1987 it's a pleasure to use PSQL. > Someone actually thinks about the implemented features. > For example, Oracle's implementation of ROWNUM gives them in the order the > rows were BEFORE the ORDER BY, which is not of much use as adding an ORDER > BY jumbles them up. Duh! LIMIT in PostgreSQL applies *after* ORDER BY, so you won't have this problem :) -- Cliff Crawford http://www.sowrong.org/ birthday party cheesecake jellybean BOOM