Обсуждение: Restricting number of entries returned

Поиск
Список
Период
Сортировка

Restricting number of entries returned

От
"Neil Burrows"
Дата:
Hi,

Is there any way of restricting the number or entries returned in an SQL
query?

For example, if you wanted to do a select that ordered the results by a
certain field, and only wanted the "Top 10" entries, is there any way to
specify that you just want the 1st 10 records?

Thanks in advance,

See ya,

Neil Burrows
  /~\  /~\ /~~~~\   E-Mail   - neil@remo.demon.co.uk
  |   \| | | () /            - nburrows@cs.strath.ac.uk
  | |\   | | () \   PGP Key  - http://www.remo.demon.co.uk/pgp/
  \_/  \_/ \____/   Internet - http://www.remo.demon.co.uk/


Re: [SQL] Restricting number of entries returned

От
Zsolt Varga
Дата:
On Wed, 15 Jul 1998, Neil Burrows wrote:

|Hi,
|
|Is there any way of restricting the number or entries returned in an SQL
|query?
|
|For example, if you wanted to do a select that ordered the results by a
|certain field, and only wanted the "Top 10" entries, is there any way to
|specify that you just want the 1st 10 records?

I don't know is there any simple solution
but you can do it with cursors

begin;
declare curs01 cursor for select artist,music,vote from musicdb order by
  vote descending;
fetch 10 in curs01;
end;

    redax

.----------------------------------------------------------.
|Zsolt Varga            | tel/fax:   +36 36 422811         |
| AgriaComputer LTD     | email:     redax@agria.hu        |
| System Administrator  | URL:       http://www.agria.hu/  |
`----------------------------------------------------------'