Let’s get down to business.
I created a Great SQL Interview GitHub repository for preparing interview questions and practicing SQL queries. I divide SQL queries into three parts: Basic (L0), Intermediate (L1) and Advanced (L2). This is the basic part of the solution.
L0: Basic SQL
- Questions related to basic SQL commands such as
SELECT
,INSERT
,UPDATE
andDELETE
. - Queries related to basic data manipulation and simple table retrieval.
Query question:
- How to display all columns and rows
customers
table? - Write a query to retrieve only
customerName
andphone
fromcustomers
table. - How to list all rows
country
It’s “America”customers
table? - Write a query to find all products
products
table with abuyPrice
Less than 50. - How to get all orders
status
“shipped” fromorders
table? - Write a query to display
productName
andquantityInStock
for all productsproducts
table. - How do you find something different?
country
value incustomers
table? - Write a query to count the total number of customers
customers
table. - How to retrieve all employees
jobTitle
Is it a “sales representative”? - Write a query to sort
products
Table basisproductName
Sort in ascending order. - how do you get
customerName
andcity
How many of all customers are located in “Paris”? - Write a query to display the first 10 orders
orders
table based onorderDate
. - How to search all
offices
Located in the United States? - Write a query to display all employees who work in the “San Francisco” office.
- How to calculate order total
orders
table? - Write a query to display
productName
of all productsproducts
where is the tableproductLine
It’s a “classic car.” - how do you find
customerName
of all customerscreditLimit
Greater than 50,000? - Write a query to get all the files that have
quantityInStock
Between 10 and 100. - How can I retrieve all orders placed in 2003?
- Write a query to display
employeeNumber
andfirstName
Employees whose last names begin with “B”.
Solutions and explanations
-
Write a query to retrieve only
customerName
andphone
fromcustomers
table. -
How do I list all rows in the Customers table where the country is “United States”?
-
Write a query to find all products
products
table with abuyPrice
Less than 50. -
show
productName
andquantityInStock
for all productsproducts
table. -
Count the total number of customers in the store
customers
table. -
Retrieve all employees
jobTitle
Is it a “sales representative”? -
sort
products
Table basisproductName
Sort in ascending order. -
Displays all employees working in offices located in San Francisco.
-
show
productName
of all productsproducts
where is the tableproductLine
It’s a “classic car.” -
turn up
customerName
of all customerscreditLimit
Greater than 50,000. -
Get all files that have
quantityInStock
Between 10 and 100. -
show
employeeNumber
andfirstName
Employees whose last names begin with “B”.
Hey my name is Jaimin Baria aka Cloud Boy…, if you liked and learned something useful like this post please add a comment and visit my Great SQL Interview GitHub repository.
Don’t forget to get started😅.
Happy coding 🧑💻