Basic SQL Interview Questions

This blog post has been created to cover basic SQL interview questions and answers and we will use questions related to SQL Server however most of them might be applicable to other database products.

These questions aim for freshers or fresh graduates, but I suspect people with SQL experience might find some questions challenging.

For more information visit SQL Server Interview questions (collection of Q&A) or SQL Interview questions that covers different kind of questions.

Contents

 

SQL Online Test

You can take one of our SQL Interview Online Tests:

Online Test
  • Beginner Level
  • Intermediate (coming soon)
  • Advanced (coming soon)
  • For Recruiters (paid - coming soon)
  •  

Basic SQL Interview Questions

Questions with * are related to SQL Server or when I am not sure if the same behavior is in different products.

First part is theory SQL questions.

Questions:

  • What does SQL Stands for?
  • What does T-SQL Stands for? *
  • What is the difference between SQL and T-SQL? *
  • Name all SQL Clauses.
  • What is the order in which you need to use SQL Clause?
  • Describe briefly all SQL Clauses
  • What is the difference between WHERE and HAVING?
  • What is a wildcard?
  • How would you join multiple tables together in a query?
  • Name all joins type you know.
  • Describe each join type.
  • What is a subquery?
  • What is a derived table?
  • What is an aggregate function?
  • What are the rules when you want to use aggregate functions?
  • What is the difference between deterministic vs non-deterministic functions?
  • How are NULLs handled in aggregate functions? *
  • How to use aggregate function with unique list of values? *
    • For instance count orders and count unique customers
  • Describe all types of aggregate functions you know. 

 

Second part is practice. Remember the best practice test is to ask the candidate to write the query in front of you.

Questions:

  • Return customers that are more than 18 years old from today.
  • Show 2011 total sales amount by region
  • Return top 10 customers (total sales amount in 2011)
  • Show customers that own more than 1 car and spend in 2011 more than £2,000
  • Show customers that haven't placed an order in the last 12 months
  • Show average number of orders by customer
  • Show average spend by customer
  • Show total number of unique products sold in 2011
  • Return bottom 10 customer which spend at least £2,000 in 2011
  • Divide top 100 customers into 10 groups. From 1 to 10.
  • Show customer with the most recent order on the system
  • Show customers that:
    • Were born before 1983 and live in UK
    • Own more than 2 cars

 

Basic SQL Interview Questions and Answers

I started with questions and I will add answers when I have some more time.

If you would like to learn more about SQL visit our SQL Tutorial if you want to get a qualitification you can visit our exam guide for 98-364 Database Fundamentals (basics that everyone should know!) and Exam guide for 70-461 Querying with SQL Server 2012 (this one requires more SQL skills and knowledge).

 

Take care

Emil

 

 


SHARE:


Name: feather
Comment:

What is the most common SQL question asked in interviews?

I'll give you the answer when I have more time


Date Posted: 05/12/2012 5:42:27 PM




Disclaimer: While every caution has been taken to provide our readers with most accurate information and honest analysis, please use your discretion before taking any decisions based on the information in this blog. Author will not compensate you in any way whatsoever if you ever happen to suffer a loss/inconvenience/damage because of/while making use of information in this blog.