SALARY : SQL INTERVIEW QUERIES EXAMPLES FOR FRESHER AND EXPRINCED SET-4

Hey this is 4th set of SQL Interview Queries series, this set containing IN,NOT IN and Salary related SQL queries which is asked most fre...

Hey this is 4th set of SQL Interview Queries series, this set containing IN,NOT IN and Salary related SQL queries which is asked most frequently in every sql server interview, so this set containing most important salary related interview queries with example.

So lets start SQL Quiz. SET-4 (31-41)
Related Tables:-



31. Select only one/top 1 record from "EmployeeDetail" table.
Ans: SELECT TOP 1 * FROM [EmployeeDetail]


32. Select all employee detail with First name "Vikas","Ashish", and "Nikhil".
Ans: SELECT * FROM [EmployeeDetail] WHERE FirstName IN('Vikas','Ashish','Nikhil')


33. Select all employee detail with First name not in "Vikas","Ashish", and "Nikhil".
Ans: SELECT * FROM [EmployeeDetail] WHERE FirstName NOT IN('Vikas','Ashish','Nikhil')


34. Select first name from "EmployeeDetail" table after removing white spaces from right side
Ans: SELECT RTRIM(FirstName) AS [FirstName] FROM [EmployeeDetail]


35. Select first name from "EmployeeDetail" table after removing white spaces from left side
Ans: SELECT LTRIM(FirstName) AS [FirstName] FROM [EmployeeDetail]


36. Display first name and Gender as M/F.(if male then M, if Female then F)
Ans: SELECT FirstName, CASE  WHEN Gender = 'Male' THEN 'M'
WHEN Gender = 'Female' THEN 'F' END AS [Gender]
FROM [EmployeeDetail]


37. Select first name from "EmployeeDetail" table prifixed with "Hello "
Ans: SELECT 'Hello ' + FirstName FROM [EmployeeDetail]


38. Get employee details from "EmployeeDetail" table whose Salary greater than 600000
Ans: SELECT * FROM [EmployeeDetail] WHERE Salary > 600000


39. Get employee details from "EmployeeDetail" table whose Salary less than 700000
Ans: SELECT * FROM [EmployeeDetail] WHERE Salary < 700000


40. Get employee details from "EmployeeDetail" table whose Salary between 500000 than 600000
Ans: SELECT * FROM [EmployeeDetail] WHERE Salary BETWEEN 500000 AND 600000


41. Select second highest salary from "EmployeeDetail" table.
Ans: SELECT TOP 1 Salary FROM
(SELECT TOP 2 Salary FROM [EmployeeDetail] ORDER BY Salary DESC) T ORDER BY Salary ASC


Click here for next set(MORE THAN 100 QUERIES)

Related

SQL SERVER 777428884742364757

Post a comment

  1. very helpful

    ReplyDelete
  2. very helpful...sir please send me pdf on.....mbhosale109@gmail.com

    ReplyDelete
  3. I want some SQL queries related to fresher and experience interview question.
    This is m mail I'd: sadana.5b2@gmail.com.
    Plz send me sir...

    ReplyDelete
  4. Please mail me the pdf file at jmehul64.mj@gmail.com

    ReplyDelete
  5. the answer for question 41 is wrong.
    It should be

    SELECT TOP 1* from (SELECT TOP 2* FROM EmployeeDetails order by SALARY ASC) T
    order by SALARY DESC

    ReplyDelete
    Replies
    1. that whole query is creates another table that table named as 'T'

      Delete
  6. 41.Ans also be like

    select MAX(Salary) from EmployeeDetail where Salary <(Select MAX(Salary) from EmployeeDetail)

    ReplyDelete
  7. sir very helpful article can you please share me these Q and A @shabashi2482@gmail.com
    thanks in advance

    ReplyDelete

emo-but-icon

Follow Us

Recent

Comments

Donate

Side Ads

Text Widget

Connect Us

Sql Server 2017 Interview Questions
Sql Server Basic Interview Query Set-1
Sql Server Basic Interview Query Set-2
Sql Server Date-Time Interview Query SET-3
Sql Server Salary Interview Query SET-4
Sql Server Group By Interview Query SET-5
Sql Server Join Interview Query SET-6
Sql Server Tricky Join Interview Query SET-7
Sql Server DDL Interview Query SET-8
Small but very Tricky Sql Server Query SET-9
Very Much Tricky Query (not 4 fresher)SET-10
Sql Server Complex Interview Query SET-11
Sql Server Datatype Interview Questions
Sql Server View Interview Questions
Sql Server Index Interview Questions
TCS Tricky Sql Interview Queries
HCL Sql Interview Queries
Sql Server SP Interview Questions
Sql Server Trigger Interview Questions
Sql Server Temp Table Interview Questions
Sql Server 2016 Interview Questions
Sql Server Performance Tuning Interview Q.
Sql Server Constraints Interview Questions
Sql Server Storage/Size Interview Questions
Sql Server Very Basic Interview Questions
Sql Server Quiz for Fresher
Sql Server Icon Quiz for All
Sql Server 300+ Theoretical Interview Questions
Sql Server Complete Set

ASP.NET AND JQUERY INTERVIEW QUESTION
ASP.NET: Web Config Interview Question
ASP.NET: View State Interview Question
ASP.NET: Session Interview Question
ASP.NET: Session Interview Question 
ASP.NET: Security Interview Question
ASP.NET: Catching Interview Question
C# OOPS Interview Question
MORE Interview Question
JQUERY: Interview Question Set-1
JQUERY: Interview Question Set-2
JAVA-SCRIPT: Interview Question Set-1
JAVA-SCRIPT: Interview Question Set-2
ASP.NET MVC: Interview Question Set-1

POPULAR POSTS
10 MOST DIFFICULT INTERVIEW QUESTIONS
5 BEST INTERVIEW TIPS
YOUR 10 MISTAKE DURING INTERVIEW
2016 TOP 20 GROUP DISCUSSION TOPICS
HOW SQL PERFORMANCE AFFECTED BY DATATYPE
item