Let's come to the point.
I have created an Awesome SQL Interview GitHub repo to prepare for interview questions and practice SQL queries. I have divided the SQL queries into three sections: Basic (L0), Intermediate (L1), and Advanced (L2). This is the solution for the basic section.
L0: Basic SQL
- Questions related to basic SQL commands such as
SELECT,INSERT,UPDATE, andDELETE. - Queries related to basic data manipulation and retrieval from simple tables.
Query Questions:
- How do you display all columns and rows from the
customerstable? - Write a query to retrieve only the
customerNameandphonefrom thecustomerstable. - How do you list all rows where
countryis 'USA' in thecustomerstable? - Write a query to find all products in the
productstable with abuyPriceless than 50. - How do you fetch all orders with a
statusof 'Shipped' from theorderstable? - Write a query to display the
productNameandquantityInStockfor all products in theproductstable. - How do you find the distinct
countryvalues in thecustomerstable? - Write a query to count the total number of customers in the
customerstable. - How do you retrieve all employees whose
jobTitleis 'Sales Rep'? - Write a query to sort the
productstable byproductNamein ascending order. - How do you fetch the
customerNameandcityof all customers located in 'Paris'? - Write a query to display the top 10 orders from the
orderstable based on theorderDate. - How do you retrieve all
officeslocated in the USA? - Write a query to display all employees who work in the office located in 'San Francisco'.
- How do you calculate the total number of orders placed in the
orderstable? - Write a query to display the
productNameof all products in theproductstable whereproductLineis 'Classic Cars'. - How do you find the
customerNameof all customers whosecreditLimitis greater than 50,000? - Write a query to fetch all products that have a
quantityInStockbetween 10 and 100. - How do you retrieve all orders placed in the year 2003?
- Write a query to display the
employeeNumberandfirstNameof employees whose last names start with 'B'.
Solution with explanation
How do you display all columns and rows from the
customerstable?

Write a query to retrieve only the
customerNameandphonefrom thecustomerstable.

How do you list all rows where country is 'USA' in the customers table?

Write a query to find all products in the
productstable with abuyPriceless than 50.

Fetch all orders with a
statusof 'Shipped' from theorderstable.

Display the
productNameandquantityInStockfor all products in theproductstable.

Fetch the
customerNameandcityof all customers located in 'Paris'.

Display the top 10 orders from the
orderstable based on theorderDate.

Display all employees who work in the office located in 'San Francisco'.

Calculate the total number of orders placed in the
orderstable.

Display the
productNameof all products in theproductstable whereproductLineis 'Classic Cars'.

Find the
customerNameof all customers whosecreditLimitis greater than 50,000.

Fetch all products that have a
quantityInStockbetween 10 and 100.

Display the
employeeNumberandfirstNameof employees whose last names start with 'B'.

Hey, My name is Jaimin Baria AKA Cloud Boy..., If you have enjoyed and learned something useful, like this post, add a comment, and visit my Awesome SQL Interview GitHub repo.
Don't forget to give it a start 😅.
Happy Coding 🧑💻
Other Posts
- Part 1
- L0: Basic SQL
- L1: Intermediate SQL
- L2: Advanced SQL - Will Come soon
🛠️ Fixes Suggested by Readers
- Fetch all products that have a
quantityInStockbetween 10 and 100.
Big thanks to Simon Green
for pointing out this<= >=mistake. Your feedback helped improve this article for everyone! 🙌






Top comments (7)
Great article.
For answer 18, the SQL for the second statement should be
quantityInStock >= 10 AND quantityInStock <= 100. TheBETWEENfunction includes both the start and end values. Being really pedantic, the 20th query shouldn't havelastNamein theSELECTclause.Yes, you are right about answer 18, and I have added
lastNamefor convenience.For 12 the answer depends on the dialect of SQL.
In T-SQL (Microsoft) you do select top 10 rather than use the limit keyword
In oracle you have to select top 10 *from (select ... Order by ....) As X
thanks for sharing.
.
Good!
Some comments may only be visible to logged-in visitors. Sign in to view all comments.