Path: utzoo!utgpu!watmath!iuvax!cica!tut.cis.ohio-state.edu!quanta.eng.ohio-state.edu!segel From: segel@quanta.eng.ohio-state.edu (Gargoyle) Newsgroups: comp.databases Subject: Re: How do you do this query? Keywords: SQL, query Message-ID: <3568@quanta.eng.ohio-state.edu> Date: 20 Nov 89 21:12:56 GMT References: <940@cirrus.stsci.edu> <1989Nov20.190046.12833@indetech.com> Reply-To: segel@quanta.eng.ohio-state.edu (Gargoyle) Organization: The Ohio State University Dept of Electrical Engineering Lines: 51 In article <1989Nov20.190046.12833@indetech.com> rec@indetech.UUCP (Rick Cobb) writes: > >You use the ``group by'' construct. Like so, using ORACLE version 6.0: [Example delted] >-- >____*_ Rick Cobb rcobb@indetech.uucp, sun!indetech!rcobb Rick you really didn't answer his question. Just touted your oracle knowlege . In response to the original posting, "Get me a list of the 10 oldest employees" sql statement would be something like SELECT * from employee ORDER by age DESC Which will order the list of employees by age in descending ages. Now, this is only half of the solution. To select only the first 10, you would have to use a cursor. (Or for those who use a database in which you can specify the size of the selection you need to get the appropriate syntax.) Since I do not wish to use a database language, here is roughly the solution: Build sql statement foo; Declare cursor bar for statement foo; Open cursor foobar fetch first into data_rec[1].* for i = 2 to 9 fetch next into data_rec[i].* end for {* Now display the info *} To the original poster, is this what you wanted? -Mike Segel "I only know half the answer(s)" -- -Mike Segel segel@icarus.eng.ohio-state.edu (614) 294-3350 "These opinions are my own and in no way reflect those of the University or the E E Dept.(Although there are those who probably share them!)