Top 80 + SQL Query Interview Questions and Answers with Examples

    601 Votes

 "SQL Order By" Interview Questions

15. Get all employee details from the employee table order by First_Name Ascending
Select * from employee order by FIRST_NAME asc


16. Get all employee details from the employee table order by First_Name descending

Select * from employee order by FIRST_NAME desc

 

17. Get all employee details from the employee table order by First_Name Ascending and Salary descending
Select * from employee order by FIRST_NAME asc,SALARY desc

 

"SQL Where Condition" Interview Questions

18. Get employee details from employee table whose employee name is “John”
Select * from EMPLOYEE where FIRST_NAME='John'

19. Get employee details from employee table whose employee name are “John” and “Roy”
Select * from EMPLOYEE where FIRST_NAME in ('John','Roy')

20. Get employee details from employee table whose employee name are not “John” and “Roy”
Select * from EMPLOYEE where FIRST_NAME not in ('John','Roy')
Immediate Job Openings in Govt Bank Mechanical Civil Electrical Defence - Apply Now

 

"SQL Wild Card Search" Interview Questions

21. Get employee details from employee table whose first name starts with 'J'

Select * from EMPLOYEE where FIRST_NAME like 'J%'


22. Get employee details from employee table whose first name contains 'o'

Select * from EMPLOYEE where FIRST_NAME like '%o%'


23. Get employee details from employee table whose first name ends with 'n'

Select * from EMPLOYEE where FIRST_NAME like '%n'

"SQL Pattern Matching" Interview Questions


24. Get employee details from employee table whose first name ends with 'n' and name contains 4 letters

Select * from EMPLOYEE where FIRST_NAME like '___n' (Underscores)


25. Get employee details from employee table whose first name starts with 'J' and name contains 4 letters

Select * from EMPLOYEE where FIRST_NAME like 'J___' (Underscores)


26. Get employee details from employee table whose Salary greater than 600000

Select * from EMPLOYEE where Salary >600000


27. Get employee details from employee table whose Salary less than 800000

Select * from EMPLOYEE where Salary <800000


28. Get employee details from employee table whose Salary between 500000 and 800000

Select * from EMPLOYEE where Salary between 500000 and 800000


29. Get employee details from employee table whose name is 'John' and 'Michael'

Select * from EMPLOYEE where FIRST_NAME in ('John','Michael')
Page 2 of 7

Related Articles

Database & SQL Interview Questions
Oracle Interview Questions and Answers on SQL Queries and Database Theory
Advanced SQL Interview Questions and Answers
SQL Server Interview Questions and Answers

Popular Videos

How to speak to people

How to speak so that people want to listen.

Got a tip or Question?
Let us know