2

I want to ask some records from an ordered table.

select * from table_name order by something desc limit 4;

This is the error message (is the 'limit 4' line):

ORA-00933: SQL command not properly ended
00933. 00000 -  "SQL command not properly ended"
*Cause:    
*Action:
Error at Line: 7 Column: 1
Damien_The_Unbeliever
  • 220,246
  • 21
  • 302
  • 402
kicsitiger
  • 45
  • 4

1 Answers1

2

use ROWNUM to limit the number of rows returned by a query

http://docs.oracle.com/cd/B28359_01/server.111/b28286/pseudocolumns009.htm#SQLRF00255

select * 
  (SELECT * FROM table_name ORDER BY someval desc)
 WHERE ROWNUM < 5;
Nagaraj S
  • 12,563
  • 6
  • 30
  • 50