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
 select query to fetch particular name at the top 5

Author  Topic 

dhinasql
Posting Yak Master

195 Posts

Posted - 2009-04-21 : 10:51:11
I need to select fields from the table,where the values are only top 5. In which the first value should always come as default 'abc'

for ex: select top 5 salary from employee where ---- emp='abc'

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2009-04-21 : 10:54:27
select top 5 salary from employee where ---- emp like 'abc%'

may be like this....





iF theRe iS a wAy iN tHen theRe iS a wAy oUt..
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2009-04-21 : 10:55:44
select top 5 salary
from employee
order by case when emp='abc' then 0 else 1 end ,
salary desc


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

dhinasql
Posting Yak Master

195 Posts

Posted - 2009-04-21 : 23:39:51
Thank you got the query
Go to Top of Page
   

- Advertisement -