| Author |
Topic |
|
shammu1978
Starting Member
2 Posts |
Posted - 2007-04-16 : 09:16:04
|
| HiI have table named employee and trying to write an sql query to pull the third highest salary from the employee table with his name,employeenumber,department? |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-04-16 : 09:24:23
|
| [url]http://www.sqlteam.com/item.asp?ItemID=566[/url]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-04-16 : 10:13:26
|
| Do google search on Find Nth maximum salaryMadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-16 : 11:10:15
|
| C'mon guys. He is using SQL Server 2005.At least show him methods utilizing ROW_NUMBER() function...Peter LarssonHelsingborg, Sweden |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-04-16 : 22:58:45
|
quote: Originally posted by Peso C'mon guys. He is using SQL Server 2005.At least show him methods utilizing ROW_NUMBER() function...Peter LarssonHelsingborg, Sweden
Not everyone is using MadhivananFailing to plan is Planning to fail |
 |
|
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2007-04-16 : 23:04:17
|
| This article is really good. It should point you in the right direction.http://www.sqljunkies.com/HowTo/4E65FA2D-F1FE-4C29-BF4F-543AB384AFBB.scuk |
 |
|
|
shammu1978
Starting Member
2 Posts |
Posted - 2007-04-17 : 06:10:22
|
| Thanks for all of your comments, but nobody has given a correct reply."Failing" to "plan" is "Planning" to "fail" this what all are we doing right now. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-17 : 06:24:25
|
| What have you tried so far?Post what you have tried and we can help you.Peter LarssonHelsingborg, Sweden |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-04-17 : 07:09:26
|
quote: Originally posted by shammu1978 Thanks for all of your comments, but nobody has given a correct reply."Failing" to "plan" is "Planning" to "fail" this what all are we doing right now.
Select columns from tablewhere sal=(Find 3rd Maximum query)MadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-17 : 07:17:11
|
Madhi, don't take it personal... Peter LarssonHelsingborg, Sweden |
 |
|
|
bpgupta
Yak Posting Veteran
75 Posts |
Posted - 2007-04-17 : 07:20:49
|
| try this querySelect top 1 columnname from mytablewhere sal =(Select sal from mytable order by Desc)Hope it will work fine |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-04-17 : 07:24:59
|
| "C'mon guys. He is using SQL Server 2005.At least show him methods utilizing ROW_NUMBER() function..."I posted link only to let him/her know that there is pretty nice search functionality on this site and he can use it for his benefit.As far as forum is concerned, I don't think he is using SQL 2005..It's my feeling that posters are just not paying much attention to the forum names anymore.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
bpgupta
Yak Posting Veteran
75 Posts |
Posted - 2007-04-17 : 07:28:55
|
| ignore the first statement , u can try this one SELECT TOP 1 Emp_ID, SalaryFROM (SELECT TOP 2 Emp_ID, Salary FROM Emp_Det ORDER BY Salary DESC) aORDER BY Salary ASC |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-04-17 : 11:27:48
|
| when you write "Thanks for all of your comments, but nobody has given a correct reply" what we see is "I just want the answer to my homework, I don't want to learn SQL"[Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-04-17 : 11:30:05
|
quote: Originally posted by Peso Madhi, don't take it personal... Peter LarssonHelsingborg, Sweden
No MadhivananFailing to plan is Planning to fail |
 |
|
|
|