SQL Interview Questions - Basics


  1. Write an SQL query to fetch “FIRST_NAME” from Worker table using the alias name as <WORKER_NAME>
  2. Write an SQL query to fetch “FIRST_NAME” from Worker table in upper case
  3. Write an SQL query to fetch unique values of DEPARTMENT from Worker table
  4. Write an SQL query to print the first three characters of FIRST_NAME from Worker table Write an SQL query to print the first three characters of FIRST_NAME from Worker table
  5. Write an SQL query to find the position of the alphabet (‘a’) in the first name column ‘Amitabh’ from Worker table
  6. Write an SQL query to print the FIRST_NAME from Worker table after removing white spaces from the right side
  7. Write an SQL query to print the DEPARTMENT from Worker table after removing white spaces from the left side
  8. Write an SQL query that fetches the unique values of DEPARTMENT from Worker table and prints its length
  9. Write an SQL query to print the FIRST_NAME from Worker table after replacing ‘a’ with ‘A’
  10. Write an SQL query to print the FIRST_NAME and LAST_NAME from Worker table into a single column COMPLETE_NAME A space char should separate them
  11. Write an SQL query to print all Worker details from the Worker table order by FIRST_NAME Ascending
  12. Write an SQL query to print all Worker details from the Worker table order by FIRST_NAME Ascending and DEPARTMENT Descending
  13. Write an SQL query to print details for Workers with the first name as “Vipul” and “Satish” from Worker table
  14. Write an SQL query to print details of workers excluding first names
  15. Write an SQL query to print details of Workers with DEPARTMENT name as “Admin”
  16. Write an SQL query to print details of the Workers whose FIRST_NAME contains ‘a’
  17. Write an SQL query to print details of the Workers whose FIRST_NAME ends with ‘a’
  18. Write an SQL query to print details of the Workers whose FIRST_NAME ends with ‘h’ and contains six alphabets
  19. Write an SQL query to print details of the Workers whose SALARY lies between 100000 and 500000
  20. Write an SQL query to print details of the Workers who have joined in Feb’2014
  21. Write an SQL query to fetch the count of employees working in the department ‘Admin’
  22. Write an SQL query to fetch worker names with salaries >= 50000 and <= 100000
  23. Write an SQL query to fetch the no of workers for each department in the descending order
  24. Write an SQL query to print details of the Workers who are also Managers
  25. Write an SQL query to fetch duplicate records having matching data in some fields of a table
  26. Write an SQL query to show only odd rows from a table
  27. Write an SQL query to show only even rows from a table
  28. Write an SQL query to clone a new table from another table
  29. Write an SQL query to fetch intersecting records of two tables
  30. Write an SQL query to show records from one table that another table does not have
  31. Write an SQL query to show the current date and time
  32. Write an SQL query to show the top n (say 10) records of a table
  33. Write an SQL query to determine the nth (say n=5) highest salary from a table
  34. Write an SQL query to determine the 5th highest salary without using TOP or limit method
  35. Write an SQL query to fetch the list of employees with the same salary
  36. Write an SQL query to show the second highest salary from a table
  37. Write an SQL query to show one row twice in results from a table
  38. Write an SQL query to fetch intersecting records of two tables
  39. Write an SQL query to fetch the first 50% records from a table
  40. Write an SQL query to fetch the departments that have less than five people in it
  41. Write an SQL query to show all departments along with the number of people in there
  42. Write an SQL query to show the last record from a table
  43. Write an SQL query to fetch the first row of a table
  44. Write an SQL query to fetch the last five records from a table
  45. Write an SQL query to print the name of employees having the highest salary in each department
  46. Write an SQL query to fetch three max salaries from a table
  47. Write an SQL query to fetch three min salaries from a table
  48. Write an SQL query to fetch nth max salaries from a table
  49. Write an SQL query to fetch departments along with the total salaries paid for each of them
  50. Write an SQL query to fetch the names of workers who earn the highest salary