Preview Content - log in or become a member

SQL Interview Questions and Answers

Welcome to our Top 13 SQL Interview Questions and Answers page, we I start with basic questions, move on to intermediate level and finish on advanced questions.

NOTE: If you would like to focus on basic SQL interview questions only then we recommend visiting our Basic Interview Q&As page

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:

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

Question 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]

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

Question 4: How would apply date range filter? [answer]

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

Question 6: How do you find orphans? [answer]

Question 7: How would you solve the following sql queries using today's date: First day of previous month, First day of current month, Last day of previous month, Last day of current month? [answer]

Questions For Experienced:

Question 8You 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]

Question 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:

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

Question 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]

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

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

Questions with answers

Questions For Freshers:

Question 1: What type of joins have you used? [all questions]

Answer: Joins knowledge is a MUST HAVE. This interview question is quite nice because most people have used inner join and (left/right) outer join which is rather mandatory knowledge but those more experienced will also mention cross join and self-join. In SQL Server you can also get full outer join. Join also strongly relate to understanding database concepts which are very important.

Question 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.[all questions]

Are you a member? Log In

Membership plans from just 6.00 USD*

* Currency: USD (US Dollar )
2500+ accounts so far

Plans:
Bronze
6.00 USD
Silver
9.00 USD
Gold
12.00 USD
6 Courses
T-SQL (3), SSRS (1), SSIS(1), Excel (1)
Watch Video
75 Mini Courses
T-SQL (34), SSRS (7), SSIS(16), + more
300+ videos and 300+ Articles
38
(part of
Courses)
Progress Tracking
21 Interview Q&As pages
T-SQL (8), SSRS (3), SSIS(4), Other (6)
Forum
11 Webinar Recordings
T-SQL (1), SSRS (9), Career(1)
1 DIY Project (beta)
70-461 Tests
Watch Video
60 days, 100% Money Back Guarantee
Instant Activation
Duration:
Bronze
Silver
Gold
Valid for: 1 month 6.00 USD
sign up
9.00 USD
sign up
12.00 USD
sign up
Valid for: 3 months
10% off
16.00 USD
sign up
24.00 USD
sign up
32.00 USD
sign up
Valid for: 6 months
20% off
28.00 USD
sign up
43.00 USD
sign up
57.00 USD
sign up
Valid for: 1 year
30% off
50.00 USD
sign up
75.00 USD
sign up
100.00 USD
sign up
Valid for: 2 years
40% off
86.00 USD
sign up
129.00 USD
sign up
172.00 USD
sign up
Valid for: lifetime
50% off
108.00 USD
sign up
162.00 USD
sign up
216.00 USD
sign up


Did you find this page useful?
+8  |  -0
(8 Votes)