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?
Answers were Sorted based on User's Feedback
Answer / 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 ? | 4 Yes | 0 No |
Answer / 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 |
Answer / suraj
This query does execute, you stupid.
Have some self respect. Do not post comments unless you are
very sure about it.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / haris
yah this query works fine and return the 2nd highest salary.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / chintan
First of all this query doesn't execute. I tried it on SQL
2005 and kept getting error.
| Is This Answer Correct ? | 0 Yes | 5 No |
Can group functions be used in the order by clause in ms sql server?
What are Spatial data types in SQL Server 2008
What is the security principal at the database level that represents your session?
What are the pre-defined functions in the sql server?
is it possible to use a variable in a query with the IN clause (a,b,c..z), without getting quotes or conversion errors?
What is the difference between Drop and Truncate
How do I open a .db file?
Explain the functionalities that views support?
employee table has employee id ----------- empid ---------------- 1 2 3 3 3 4 5 5 5 6 6 6 7 here the values r repeated two times.how to select the repeated values only.i.e 3,5,6 should alone come.
What methods do you follow to protect from sql injection attack?
How to insert stored procedure result into temporary table?
after migrating the dts packg to ssis by using migrtn wizrd in 2005. iam not able to open ssis pack and getting error. what r those errors? how to resolve?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)