select * into sam from s1
select * from sam
--get 2nd highest sal.emp
- select top 1 * from sam where sal in (select top 2 sal from sam order by sal desc) order by sal
- select * from sam tbl1 where 1=(select count(distinct sal) from sam tbl2 where tbl1.sal<tbl2.sal)
- select top 1 * from ( select top 2 * from sam order by sal desc)s order by sal
- select * from (select *, rn=row_number() over(order by sal desc) from sam) s where rn=2
- select * from (select *, rn = dense_rank() over(order by sal desc) from sam) s where rn=2
--get 2nd lowest sal.emp
- select top 1 * from sam where sal in (select top 2 sal from sam order by sal) order by sal desc
Max possible columns per a table in sqlserver is 1024 but in oracle 1000
Max possible databases : 32,767
No comments:
Post a Comment