| From: | Antonio <psql(at)msux(dot)cjb(dot)net> |
|---|---|
| To: | pgsql-es-ayuda(at)postgresql(dot)org |
| Subject: | Re: rownum |
| Date: | 2005-12-29 18:39:26 |
| Message-ID: | 20051229183922.8320.PSQL@msux.cjb.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-es-ayuda |
> Y si quiero que un query arroje a lo mucho solo 3 registros como se deberia
> hacer? (en ORACLE "where rownum<=3")
>
The LIMIT and OFFSET clauses of SELECT allow the user to specify which
rows to return. For example, suppose customer has 1,000 rows with
customer_id values ranging from 1 to 1,000. Figure [*] shows queries
using LIMIT and LIMIT...OFFSET.
test=> SELECT customer_id FROM customer ORDER BY customer_id LIMIT 3;
customer_id
-------------
1
2
3
(3 rows)
test=> SELECT customer_id FROM customer ORDER BY customer_id LIMIT 3 OFFSET 997;
customer_id
-------------
998
999
1000
(3 rows)
The first query sorts the table by customer_id and uses LIMIT to return
the first three rows. The second query is similar, except that it skips
to the 997th row before returning three rows.
* * *
Podemos ver más información en
http://www.postgresql.org/docs/8.1/interactive/queries-limit.html
http://www.postgresql.org/files/documentation/books/aw_pgsql/node115.html
P.D. Roberto, tu último mensaje tienen fecha de octubre, es posible que
no te contesten en esta lista por los problemas que ello causa.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Felipe Araoz Ramos | 2005-12-29 18:53:13 | Fwd: Conectar PostgreSQL con LInux |
| Previous Message | Alvaro Herrera | 2005-12-29 17:51:01 | Re: Formación Postgresql |