Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!ames!sgi!shinobu!odin!hargrove From: hargrove@harlie.sgi.com (Mark Hargrove) Newsgroups: comp.databases Subject: Re: Simple SQL question Message-ID: Date: 22 Nov 89 17:25:39 GMT References: <98813@ti-csl.csc.ti.com> <1989Nov19.200834.266@mrspoc.Transact.COM> <1217@hpuviea.UUCP> Sender: news@odin.SGI.COM Organization: Silicon Graphics Inc, Mountain View, CA Lines: 42 In-reply-to: gernot@hpuviea.UUCP's message of 21 Nov 89 08:18:40 GMT In article <1217@hpuviea.UUCP> gernot@hpuviea.UUCP (Gernot Kunz) writes: >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. ^^^^^^^^ Just which *pure* SQL are you referring to?!? I think your version is just as much a "hack" as you claim Steven's is. Foo. His may take advantage of a tool outside of SQL, but at least it will work for ANY dialect of SQL (under Unix, obviously; but there's a way to do the same thing under VMS). -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Mark Hargrove Silicon Graphics, Inc. email: hargrove@harlie.corp.sgi.com 2011 N.Shoreline Drive voice: 415-962-3642 Mt.View, CA 94039