May 19, 2009 at 11:46 pm
Ignore my last post and try this CODE
---- For 2nd highest value
select max(salary) from employee_details e1
where 2 <=(select count(*) from employee_details e2 where e1.salary<= e2.salary)
---- For 2nd highest value in noncluster
select max(salary) from employee_details e1
where 2 <=(select count(distinct salary) from employee_details e2 where e1.salary<= e2.salary)
May 20, 2009 at 1:24 am
I can't believe this thread is still alive...
Maybe we'll have to write an article titled "100 ways to find 2nd highest salary"...:-D
-- Gianluca Sartori
May 20, 2009 at 6:21 am
Gianluca Sartori (5/20/2009)
I can't believe this thread is still alive...Maybe we'll have to write an article titled "100 ways to find 2nd highest salary"...:-D
Fire the 1st guy and find max(salary) . . . 😛
---------------------------------------------------------
How best to post your question[/url]
How to post performance problems[/url]
Tally Table:What it is and how it replaces a loop[/url]
"stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."
May 20, 2009 at 1:57 pm
jcrawf02 (5/20/2009)
Fire the 1st guy and find max(salary) . . . 😛
[font="Verdana"]Pay everyone the same. :-P[/font]
May 20, 2009 at 2:40 pm
Bruce W Cassidy (5/20/2009)
jcrawf02 (5/20/2009)
Fire the 1st guy and find max(salary) . . . 😛[font="Verdana"]Pay everyone the same. :-P[/font]
Or like one of my former employers decided, don't pay anyone.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
May 21, 2009 at 4:26 am
May 21, 2009 at 4:37 am
:w00t: :w00t: :w00t: :w00t: :w00t:
May be this might also work :w00t::hehe::cool:;-):-)
[Code]
--
use DB_TEST
create table employee (E_id int,Name varchar(50),Gender char(20),Age int,SALARY MONEY,constraint E_pk primary key (E_id),constraint E_chk check (Gender in ('M','F')))
SELECT SALARY FROM EMPLOYEE E1 WHERE 2=(SELECT COUNT(*) FROM EMPLOYEE E2 WHERE E1.SALARY<=E2.SALARY)
--
[/Code] :alien:
Tanx 😀
May 21, 2009 at 6:26 am
Paul White (5/21/2009)
Would paying everyone NULL work?:w00t:
No, because NULL is undefined, could be $1, could be $1,000,000,000.00. You'd be bankrupt in a heartbeat :hehe:
---------------------------------------------------------
How best to post your question[/url]
How to post performance problems[/url]
Tally Table:What it is and how it replaces a loop[/url]
"stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."
Viewing 8 posts - 16 through 22 (of 22 total)
You must be logged in to reply to this topic. Login to reply