home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / database / oracle / 1439 < prev    next >
Encoding:
Text File  |  1992-08-31  |  1.6 KB  |  41 lines

  1. Newsgroups: comp.databases.oracle
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!destroyer!news.iastate.edu!news
  3. From: GO.MSB@isumvs.iastate.edu 
  4. Subject: Re: SQL*plus -- limiting maximum number of returned rows?
  5. Message-ID: <1992Aug31.204947.7478@news.iastate.edu>
  6. Sender: news@news.iastate.edu (USENET News System)
  7. Organization: Iowa State University, Ames IA
  8. Distribution: usa
  9. Date: Mon, 31 Aug 1992 20:49:47 GMT
  10. Lines: 29
  11.  
  12. In article <BtuK40.8By@ef2007.efhd.ford.com>,
  13. wwm@ef2007.efhd.ford.com (William Meahan) writes:
  14. >In SQL*Plus (not embedded SQL!) is there any way of limiting the number
  15. >of rows returned by a query?
  16. >
  17. >I am working on a report that is supposed to find the "top 5" items in
  18. >a catagory.  The query returns 0 or more rows based on the selection
  19. >criteria, sorted in the appropriate order.  Some queries return a dozen
  20. >or more rows, but I'm only interested in the first 5.
  21. >
  22. >If I were using embedded SQL in a C program (or a perl script using
  23. >oraperl) the solution would be trivial.  For internal reasons, however,
  24. >I'm stuck with using SQL*Plus.
  25. >
  26. >Any ideas?
  27. >--
  28. >Bill Meahan                     |EFHD Information Systems Staff
  29. >Technical Consultant            |Ford Motor Company
  30. >wwm@ef2007.efhd.ford.com        | +1 313 487 6122
  31. >...!fmsrl7!ef2007!wwm           |I'm not paid to speak for Ford!
  32. ---------------------------------
  33.   try   WHERE ROWNUM < 6
  34.  
  35. ALthough this works, I hate it.  If the query returns 2000 rows, it still
  36. does and you wait for it to do so.  It then hands you the first 5 or whatever
  37. you request.  ROWNUM is a pseudo-column and doesn't exist until some rows are
  38. returned.
  39.  
  40. Marvin Beck    Iowa State University
  41.