user2659722
user2659722

Reputation:

getting error as too many values in my query

dpt_no   salary  period        start_date       end_date
------   -----   ------        ----------       --------
100 12580   15months    12-DEC-07   10-DEC-10
101 15500   19months    10-JAN-07   10-DEC-11
102 7777    18months    11-JUL-07   21-APR-11
103 9999    11months    07-JUL-07   31-JAN-11
104 8500    9months         12-MAR-07   27-MAR-11
105 10000   20months    17-SEP-07   01-AUG-11
106 25000   7months         17-NOV-07   26-JUL-11
107 100000  6months     05-MAY-07   21-JUN-11
108 35000   16months    28-FEB-08   21-JUN-11
109 5000    16months    02-DEC-08   19-AUG-11

i'm write query for giving rank to salary and getting that rank using ampersand. That query is

select salary from salary 
where &RANK=(select salary, rank() over(order by salary desc) 
as "rank" from salary  salary).

BUT i'm getting error as "too many values". can any one help me please

Upvotes: 1

Views: 198

Answers (1)

valex
valex

Reputation: 24144

It should be something like this:

select t1.salary from 
(select salary.salary, 
         rank() over(order by salary desc) 
as "rank" from salary) t1
where "rank"=&RANK

SQLFiddle demo

Upvotes: 1

Related Questions