February 7, 2006 at 7:17 am
if one has a table of 4 rows with a date column 'salary' and max(salary) returns the largest salary,
Is there a variation of max(salary) that could return the second largest salary???
February 7, 2006 at 7:39 am
This would work:
SELECT MAX(SALARY)
FROM SALARY
WHERE SALARY < (SELECT MAX(SALARY) FROM SALARY)
February 7, 2006 at 7:41 am
I solve this as follows...
This approach would allow you get any rank
Select top 1 Salary
from
(
Select top 2 Salary
from Salary
order by Salary desc
)
order by salary asc
HTH
Mathew J Kulangara
sqladventures.blogspot.com
February 8, 2006 at 3:18 am
Thank you so much for your help! it worked like a charm
February 8, 2006 at 8:23 am
select max(salary)-1 from table_name
February 10, 2006 at 9:33 am
Wayne, your query would return ((highest salary) - 1), not (second highest salary).
February 13, 2006 at 12:25 pm
Clint - thanks for clarification.
February 15, 2006 at 4:22 am
Try this Query :-
select max([2]) from tbl_excel
where [2] not in (select max([2]) from tbl_excel )
----------------------------------------------
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply