Sign In | Feedback | Donate
Katie and Emil Logo

Welcome to our SQL Interview Questions and Answers page. This page contains 13 Questions related to SQL Querying (Select) only and starts with basic questions and finishes on advanced questions.

SQL Interview questions

If you would like to focus on basic SQL questions only then we recommend visiting our Basic SQL Interview Questions and answers

Top 13 "mixed" questions

Questions are split into 3 levels:

  • For Freshers (Beginner Level),
  • For Experienced (Intermediate Level - 2 to 3 years of experience) and
  • Advanced (4 and 5 plus years of experience)

Questions For Freshers:

1. What type of joins have you used? [answer]

2. How can you combine two tables/views together? For instance one table contains 100 rows and the other one contains 200 rows, have exactly the same fields and you want to show a query with all data (300 rows). This sql interview question can get complicated. [answer]

3. What is the difference between where and having clause? [answer]

4. How would apply date range filter? [answer]

5. What type of wildcards have you used? This is usually one of mandatory sql interview question. [answer]

6. How do you find orphans? [answer]

7. How would you solve the following sql queries using today's date? [answer]

First day of previous month, First day of current month, Last day of previous month, Last day of current month

Questions For Experienced:

8. You have a table that records website traffic. The table contains website name (multiple websites), page name, IP address and UTC date time. What would be the query to show all websites visited in the last 30 days with total number or visits, total number if unique page view and total number of unique visitors (using IP Address)? [answer]

9. How to display top 5 employees with the higest number of sales (total) and display position as a field. Note that if both of employees have the same total sales values they should receive the same position, in other words Top 5 employees might return more than 5 employees. [answer]

Advanced Questions:

10. How to get accurate age of an employee using SQL? [answer]

11. This is SQL Server interview question. You have three fields ID, Date and Total. Your table contains multiple rows for the same day which is valid data however for reporting purpose you need to show only one row per day. The row with the highest ID per day should be returned the rest should be hidden from users (not returned). [answer]

12. How to return truly random data from a table? Let say top 100 random rows? [answer]

13. How to create recursive query in SQL Server? [answer]


Did you find this page helpful?
Vote Yes! Yes! [+0]  |  Vote no! No? [-0]

Author: by Emil Glownia