Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 17th, 2012  |  syntax: None  |  size: 0.46 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Oracle Row Limit
  2. ex: ID   EVENT EVENT_DESC
  3.     __   _____ __________
  4.     1723    1A    1A desc
  5.     1723    1B    1B desc
  6.     2214    2A    2A desc
  7.     2214    2B    2B desc
  8.        
  9. SELECT *
  10. FROM (
  11.    SELECT id,
  12.           event,
  13.           event_desc,
  14.           rank() over (order by id desc) as rnk
  15.    FROM your_table
  16. )
  17. WHERE rnk <= 10
  18.        
  19. SELECT TOP 10 ID FROM TABLE
  20. GROUP BY ID
  21.        
  22. SELECT ID FROM (
  23.     SELECT DISTINCT ID FROM TABLE ORDER BY ID
  24. )
  25. WHERE rownum <= 10