0

I am trying to execute following on sqlDeveloper

SELECT salary FROM emp ORDER BY salary DESC LIMIT 4, 1;

But it is throwing following error:

ORA-00933: SQL command not properly ended 00933. 00000 - "SQL command not properly ended" *Cause:
*Action: Error at Line: 1 Column: 44

asked Feb 15, 2013 at 10:46
1
  • As an aside, if you find any answers to your questions useful, it's polite to mark them as accepted. See this link dba.stackexchange.com/faq#howtoask Commented Feb 15, 2013 at 11:25

1 Answer 1

4

Oracle 11g doesn't support the LIMIT clause, though the impending 12c release is rumored to support it.

Anyway, you can do this using an analytic windowing function:

select * from
( 
 select salary, row_number() over (order by salary desc) as rn
 from emp
)
where rn = 4;

You can also do this using rownum, but I find the above way to look cleaner.

Example SQL Fiddle for you to mess around with.

answered Feb 15, 2013 at 11:19
2
  • Thanks Phil for your answer. but can you please tell me tell till which version of oracle LIMIT is supported ? Commented Feb 15, 2013 at 11:40
  • It's not supported. It is rumored to be supported in version 12c, which isn't released yet. Commented Feb 15, 2013 at 11:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.