* Robert Beer <[EMAIL PROTECTED]> 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
<http://postgresql.readysetnet.com/users-lounge/docs/7.1/postgres/sql-select.html>
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

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to