Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to retrieve the top most 5 salaries from table

Author  Topic 

rameshbhamidipati
Starting Member

2 Posts

Posted - 2008-05-12 : 05:39:35
Hi all..

I want to retrieve the top most 5 salaries from the table please help.

Thanks in advance
Ramesh.

cutiebo2t
Constraint Violating Yak Guru

256 Posts

Posted - 2008-05-12 : 05:42:13
SELECT TOP 5 COLUMNNAME
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-05-12 : 05:43:37
[code]Select top 5 *
from table
order by sal desc[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-05-12 : 05:47:31
quote:
Originally posted by cutiebo2t

SELECT TOP 5 COLUMNNAME


What do you mean?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

cutiebo2t
Constraint Violating Yak Guru

256 Posts

Posted - 2008-05-12 : 05:48:27
You're an expert. I think you understand.
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-05-12 : 05:53:50
quote:
Originally posted by cutiebo2t

You're an expert. I think you understand.



But I believe question was asked by newbie, not an expert.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-05-12 : 05:58:10
quote:
Originally posted by madhivanan

What do you mean?

He's mad because he got "no real help" here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=102622



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

rameshbhamidipati
Starting Member

2 Posts

Posted - 2008-05-12 : 05:59:18
Will this work for oracle or MySql...
Go to Top of Page

cutiebo2t
Constraint Violating Yak Guru

256 Posts

Posted - 2008-05-12 : 06:01:13
I'm glad to know that you're helping newbies. :)
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-05-12 : 06:03:54
quote:
Originally posted by rameshbhamidipati

Will this work for oracle or MySql...



Not sure. But you can check alternatives here: http://dotnet.org.za/thea/archive/2005/02/22/14715.aspx

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-12 : 06:04:55
quote:
Originally posted by rameshbhamidipati

Will this work for oracle or MySql...


You've posted in wrong forum in that case. This is a MS SQL Server forum.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-05-12 : 06:28:18
quote:
Originally posted by rameshbhamidipati

Will this work for oracle or MySql...


Will work if you use LIMIT clause

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2008-05-12 : 12:24:55
Hi,


Select top5 columnname from tablename
order by columnname desc


Be cool...
Go to Top of Page
   

- Advertisement -