Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




.NET and SQL Server interview questions - Show us top 10 salaries with names of employees in SQL?


Answer:

Let’s see a simple example to see, how exactly we can obtain entire employee name who obtains top 10 salaries.

Assuming that we have following table for Employee.

 
EmpId
 
EmpName
 
EmpSalary
 
1Alok20000
2Ashok30000
3Anand25000
4Akash18000
5Prasad33000
6Manoj30000
7Sachin40000
8Denish36000
9Rajesh24000
10Hari4000
11Ravi25000
12Kiran20000
13Shobha30000
14Pallavi43000
15Reshma41000

 
Query:-

select Employee.EmpName,Employee.EmpSalary from Employee where Employee.EmpSalary in
(select distinct top(10)Employee.EmpSalary from Employee order by Employee.EmpSalary desc)
OUTPUT:-

 
EmpNameEmpSalary
Alok20000
Ashok30000
Anand25000
Akash18000
Prasad33000
Manoj30000
Sachin40000
Denish36000
Rajesh24000
Ravi25000
Kiran20000
Pallavi43000
Reshma41000

 

You will be also interested in watching the below video, which are also asked in most of the interviews and favourable question of interviewers.


 
Please click here to see more  .NET and SQL Server  interview questions

Regards,
 
Visit Authors blog for more  .NET and SQL Server interview Question
 

Share this article   |    Print    |    Article read by 4407 times
Author:
Shivprasad koirala Koirala
I am a Microsoft MVP for ASP/ASP.NET and currently a CEO of a small E-learning company in India. We are very much active in making training videos , writing books and corporate trainings. Do visit my site http://www.questpond.com for .NET, C# , design pattern , WCF , Silverlight , LINQ , ASP.NET , ADO.NET , Sharepoint , UML , SQL Server training and Interview questions and answers
Related Articles:
Related Interview Questions: