Skip to content

Latest commit

 

History

History
43 lines (35 loc) · 4.65 KB

README.md

File metadata and controls

43 lines (35 loc) · 4.65 KB

Common SQL interview Questions and Answers

Author: Jaime M. Shaker
Email: jaime.m.shaker@gmail.com
Website: https://www.shaker.dev
LinkedIn: https://www.linkedin.com/in/jaime-shaker/

❗ If you find this repository helpful, please consider giving it a ⭐. Thanks! ❗

Note

Introduction:

This repository contains entry-level SQL interview questions that appear in many interview preperation resources found online.

All solutions were coded using PostgreSQL.

  1. How do you find duplicates in a table?
  2. How do you delete multiple entries from a table?
  3. What is the difference between union and union all?
  4. What is the difference between rank,row_number and dense_rank?
  5. Find records in a table which are not present in another table.
  6. Find second highest salary employees in each department.
  7. Find employees with greater salaries than their manager's salary.
  8. What is the difference between an inner and left join?
  9. Update a table and swap gender values.
  10. Number of records in output with different kinds of join.
  11. What is the difference between the DELETE, TRUNCATE and DROP statements?
  12. What is the difference between the NOW() and CURRENT_DATE functions?
  13. What is the difference between the ‘IN’ and ‘BETWEEN’ condition operators?
  14. What is the difference between the WHERE and the HAVING clause?
  15. From a table of names, write a query that only returns EVEN number rows.
  16. How can we copy the contents of one table to a new table?
  17. In string pattern matching, what is the difference between LIKE and ILIKE?
  18. What are Aggregate and Scalar functions in an RDBMS and can you provide an example of their use?
  19. How can you calculate the MEDIAN of a numerical field?
  20. Display two different methods to concatnate strings in PostgreSQL.
  21. How can we get the Year (month, day hour, etc...) from a timestamp?
  22. Produce a query that only returns the top 50% of the records.
  23. How can you insert a new row into a table OR update the row if it already exists?
  24. What is the use of the COALESCE() function?
  25. Is the COALESCE() function the same as the NULLIF() function?