user9817940
user9817940

Reputation: 1

how do I fix ORA-00923: FROM keyword not found where expected error in oracle 10g

I have a database schema employee like this:

create table Employee  
(  
   ID int,  
   Name varchar(20),  
   Salary float,  
   Department varchar(20)  
) ; 

but when I run this following query at oracle 10g, I get the following error:

ORA-00923: FROM keyword not found where expected

The query is

select min(salary) 
from (select distinct top 3 salary 
      from employee 
      order by salary desc
     );

How to fix it?

Upvotes: 0

Views: 437

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269853

In Oracle, you would express this as:

select min(salary)
from (select distinct salary
      from employee e
      order by salary desc
     ) s
where rownum <= 3;

select top is a SQL extension associated with SQL Sever (although used by a few other databases as well).

In Oracle 12C, you would not need a subquery:

select distinct salary
from employee
order by salary desc
offset 2 rows fetch next 1 row only

Upvotes: 2

Related Questions