Following are some of the question related to below
mentioned query?

select e1.salary from employee3 e1
where 2=
(
select count(distinct(e2.salary))
from employee3 e2 where e2.salary>=e1.salary
)

1) What the query returns?

2) How it works? - Detail explanation (what the sub query
does, why it is (where 2=)....etc...Please?

Answer Posted / ashok

Hi

1.Here query will return 2nd highest salary
2.here 2= i.e 2nd heigest similary if we set N in place
of 2 then it will returen Nth heigest salary
where n =1,2,3,4.....

Hope it will help u

Ashok

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I perform an unattended install of sql server 2000?

755


What is table-valued sub query?

734


What is cross join in sql server joins?

797


How to get a list of columns in a view using "sys.columns" in ms sql server?

719


What are sp_configure commands and set commands?

717






wat wil hapn if we give the both read and deny read permission to user?

1857


What is SubQuery in SQL Server 2008

714


What will be query used to get the list of triggers in a database?

746


How to check what was the last restore transaction LSN in Log shipping or Mirroring? when we don't have a Monitor or witness server.

3561


what happens on checkpoint? : Sql server database administration

694


How to return the top 5 rows from a select query in ms sql server?

778


what is package and it uses and how can u call a package

1769


What is reference section?

668


Does index slows down insert statements?

750


What will happen if a column containing char type data is changed to the nchar data type?

797