Re: Simple SQL question.

From: Paul Andlinger <nm_andli_at_rcvie.co.at>
Date: Wed, 30 Jun 1993 17:48:38 GMT
Message-ID: <1993Jun30.174838.27674_at_rcvie.co.at>


In article <486_at_ecsa01.encon.pge.com> gnm1_at_encon.pge.com (Gary Mercuri) writes:
>Try the following script as a formula:
>
>
>SQL> l
> 1 select last_name from employee emp
> 2 where 5 > (select count(*) from employee where last_name < emp.last_name)
> 3* order by last_name
>
>Best Wishes,
>
>Gary Mercuri
>
>-----------------------------------------------------------------------------------
>
>Chris G. vanHasselt (chrisvh_at_med.unc.edu) wrote:
>: My question has either a real simple solution or it can't be done! Is
>: there a way, without creating some sort of dummy field, to write a SQL
>: query so that instead of returning all records satisfying a where clause,
>: it returns only the first 5 records satisfying that clause.
 

>: Is there an easy way to do this?
>
>
>: Please reply to chrisvh_at_med.unc.edu
 

>: Thanks in advance
>: Chris van Hasselt
 

>: chrisvh_at_med.unc.edu

Gary's formula looks good but unfortunately doesn't work. It requires a presorted table what does not confirm to relational theory. The ORDER BY clause only sorts the SELECTED rows for output.

Paul Andlinger
Alcatel Austria Research Center Received on Wed Jun 30 1993 - 19:48:38 CEST

Original text of this message