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 |
Explain what are the basic functions for master, msdb, model, tempdb databases?
What is order of B+tree?
What is checkpoint in sql server?
How to replace given values with null using nullif()?
What is inner join in sql server joins?
What is clustered primary key?
Can sql servers linked to other servers like oracle?
wat is mean by trigger?.......normally wat use......when trigger used in sql........... plz cleary say with example.......
How can I create a plain-text flat file from SQL Server as input to another application?
If a user does not have permission to a table, but has permission to a view created on it, will he be able to view the data in table?
What is Stored Procedure? What is Views in sql server? Difference between a User Defined Function and a Stored Procedure Difference between a primary key and a unique key? What is a join and explain different types of joins. Difference between temp table and table variable Difference between Triggers and Stored Procedures Difference between UNION ALL Statement and UNION What is COALESCE / Why do we use COALESCE? Why we use SET ROWCOUNT in Sql How many clustered index can have a table How many types of local tables in SQL SERVER Difference between DELETE and TRUNCATE What is Aggregate Functions? What is Row_Number()? What are Ranking Functions? What is NOLOCK? What is CTE? What are the Advantages of using CTE? What is the STUFF function and how does it differ from the REPLACE function? What are the difference between clustered and a non-clustered index? What are the different index configurations a table can have? Difference between a HAVING CLAUSE and a WHERE CLAUSE? Difference between SET and SELECT Provide all the built in string function of SQL SERVER Difference between char and varchar data types Define candidate key, alternate key, composite key. What are constraints? Explain different types of constraints. What is a self join? Explain it with an example. How will you convert table row to a column comma separated value
Is it possible to run multiple publications and different type of publications from the same distribution database? : sql server replication
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)