Home » RDBMS Server » Server Administration » SQL Select number rows
SQL Select number rows [message #370844] Tue, 15 February 2000 14:17 Go to next message
CARLOS
Messages: 24
Registered: February 2000
Junior Member
How can I make a select which answer this question :
- I want the ten oldest clients of any table about
the clients in my job.( Futhermore, this table has 10000 less of clients).
?
Re: SQL Select number rows [message #370845 is a reply to message #370844] Tue, 15 February 2000 20:57 Go to previous message
Paul
Messages: 164
Registered: April 1999
Senior Member
Carlos
Try this
SELECT .whatever_else_you_want, a.client_start_dt
FROM your_table a
WHERE 10 > ( select count (*)
from your_table b
where b.client_start_dt substituting your column and table names. If more than one client is "tied" for the tenth earliest date, then more than ten records will be displayed.

I really hate this type of query, since it usually involves selecting the n highest or n lowest of a non-unique value. But without some clear way of breaking the "ties" for last place, the best thing to do is just present all the rows returned.
Regards,
Paul
Previous Topic: PL/SQL
Next Topic: MULTISELECT with SHIFT+, CTRL+
Goto Forum:
  


Current Time: Tue Apr 16 12:30:42 CDT 2024