SQL Query Interview Questions

Table of Contents

31. 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

32. Get employee details from employee table whose employee name is “John”?

SELECT * FROM EMPLOYEE WHERE FIRST_NAME='John';

33. Get employee details from employee table whose employee name are “John” and “Roy”?

SELECT * FROM EMPLOYEE WHERE FIRST_NAME IN ('John', 'Roy');

34. Get employee details from employee table whose employee name are not “John” and “Roy”?

SELECT * FROM EMPLOYEE WHERE FIRST_NAME NOT IN ('JOHN', 'ROY');

 SQL Wild Card Search

35. Get employee details from employee table whose first name starts with ‘J’?

SELECT * FROM EMPLOYEE WHERE FIRST_NAME LIKE 'J%';

36. Get employee details from employee table whose first name contains ‘o’?

SELECT * FROM EMPLOYEE WHERE FIRST_NAME LIKE '%o%';

37. Get employee details from employee table whose first name ends with ‘n’?

SELECT * FROM EMPLOYEE WHERE FIRST_NAME LIKE '%n';

SQL Pattern Matching

38. 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)

 

39. 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)

40. Get employee details from employee table whose Salary greater than 600000?

SELECT * FROM EMPLOYEE WHERE SALARY >600000;

Pages: 1 2 3 4 5 6 7 8 9 10

Translate »