Tuesday, 15 July 2014

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 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)
Visit Our New Site for HR Interview Questions Answers http://www.interviewboat.com/Company/GetCompany
Sponsored Ads

5 comments:

  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