Path: utzoo!attcan!uunet!mcsun!tuvie!hpuviea!gernot From: gernot@hpuviea.UUCP (Gernot Kunz) Newsgroups: comp.databases Subject: Re: Simple SQL question Keywords: SQL Message-ID: <1217@hpuviea.UUCP> Date: 21 Nov 89 08:18:40 GMT References: <98813@ti-csl.csc.ti.com> <1989Nov19.200834.266@mrspoc.Transact.COM> Organization: Hewlett-Packard Vienna,Austria Lines: 38 itkin@mrspoc.Transact.COM (Steven M. List) writes: >hemphill@csc000.csc.ti.com (Charles Hemphill) writes: >> List the 10 oldest employees. > select name, birthdate > from employee > order by birthdate desc >and pipe the result through "head -10"? >Otherwise, there's no way to set a limit in SQL. Oops, what a tricky UNIX hack to circumvent an obviously missing SQL functionality. In ORACLE you could do THIS: create table temptable(name ..., birthdate ...); insert into temptable select name, birthdate from employee order by birthdate desc; select name,birthdate from temptable where rownum <= 10 ; and remain in pure SQL. It requires a temporary table, though. --- Gernot Kunz gernot@hpuviea.UUCP Hewlett-Packard Austria GmbH, ...mcvax!tuvie!hpuviea!gernot A-1220 Vienna, Austria ...hplabs!hpfcla!hpbbn!hpuviea!gernot (0043) (222) 2500 x428 (9-18 CET)