28 July 2011

how to find out highest salaried employee details of a table in sqlserver



select * from tblEmp tbl1 where 0=(select count(distinct salary) from tblEmp tbl2 where tbl1.salary<tbl2.salary)

with s as (select *, row_number() over(order by sal desc) as rn from sam) select * from s where s.rn=1

max possible columns per a table in sqlserver is 1024

No comments: