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

  1. Newsgroups: comp.databases.oracle
  2. Path: sparky!uunet!comp.vuw.ac.nz!cc-server4.massey.ac.nz!M.W.Stern
  3. From: M.W.Stern@massey.ac.nz (M.W. Stern)
  4. Subject: Re: SQL*plus -- limiting maximum number of returned rows?
  5. Message-ID: <1992Aug31.223520.28312@massey.ac.nz>
  6. Organization: Massey University, Palmerston North, New Zealand
  7. References: <BtuK40.8By@ef2007.efhd.ford.com>
  8. X-Reader: NETNEWS/PC Version 2c
  9. Date: Mon, 31 Aug 92 22:35:20 GMT
  10. Lines: 39
  11.  
  12.  
  13. > In SQL*Plus (not embedded SQL!) is there any way of limiting the number
  14. > of rows returned by a query?
  15.  
  16. > I am working on a report that is supposed to find the "top 5" items in 
  17. > a catagory.  The query returns 0 or more rows based on the selection
  18. > criteria, sorted in the appropriate order.  Some queries return a dozen
  19. > or more rows, but I'm only interested in the first 5.
  20.  
  21. I believe the answer to this goes something like this,
  22.  
  23. SELECT value FROM table WHERE ROWNUM <= 5
  24.  
  25. > If I were using embedded SQL in a C program (or a perl script using 
  26. > oraperl) the solution would be trivial.  For internal reasons, however,
  27. > I'm stuck with using SQL*Plus.
  28.  
  29. I think the above solution is pretty trivial as well.
  30.  
  31. > Any ideas?
  32.  
  33.  
  34. > --
  35. > Bill Meahan
  36. > -- 
  37. > Bill Meahan            |EFHD Information Systems Staff
  38. > Technical Consultant        |Ford Motor Company
  39. > wwm@ef2007.efhd.ford.com          | +1 313 487 6122
  40. > ...!fmsrl7!ef2007!wwm           |I'm not paid to speak for Ford!
  41.  
  42.  
  43. ==============================================================================
  44. Mark Stern              | "There are holes in the sky,
  45. Analyst/Programmer      |  where the rain gets in,
  46. Massey University       |  but they're ever so small,
  47. NEW ZEALAND             |  that's why rain is thin"
  48. Internet:               |  ...
  49. M.W.Stern@massey.ac.nz  |     by Spike Milligan
  50. ==============================================================================
  51.