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
customers
table? - Write a query to retrieve only the
customerName
andphone
from thecustomers
table. - How do you list all rows where
country
is 'USA' in thecustomers
table? - Write a query to find all products in the
products
table with abuyPrice
less than 50. - How do you fetch all orders with a
status
of 'Shipped' from theorders
table? - Write a query to display the
productName
andquantityInStock
for all products in theproducts
table. - How do you find the distinct
country
values in thecustomers
table? - Write a query to count the total number of customers in the
customers
table. - How do you retrieve all employees whose
jobTitle
is 'Sales Rep'? - Write a query to sort the
products
table byproductName
in ascending order. - How do you fetch the
customerName
andcity
of all customers located in 'Paris'? - Write a query to display the top 10 orders from the
orders
table based on theorderDate
. - How do you retrieve all
offices
located 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
orders
table? - Write a query to display the
productName
of all products in theproducts
table whereproductLine
is 'Classic Cars'. - How do you find the
customerName
of all customers whosecreditLimit
is greater than 50,000? - Write a query to fetch all products that have a
quantityInStock
between 10 and 100. - How do you retrieve all orders placed in the year 2003?
- Write a query to display the
employeeNumber
andfirstName
of employees whose last names start with 'B'.
Solution with explanation
How do you display all columns and rows from the
customers
table?
Write a query to retrieve only the
customerName
andphone
from thecustomers
table.
How do you list all rows where country is 'USA' in the customers table?
Write a query to find all products in the
products
table with abuyPrice
less than 50.
Fetch all orders with a
status
of 'Shipped' from theorders
table.
Display the
productName
andquantityInStock
for all products in theproducts
table.
Fetch the
customerName
andcity
of all customers located in 'Paris'.
Display the top 10 orders from the
orders
table based on theorderDate
.
Display all employees who work in the office located in 'San Francisco'.
Calculate the total number of orders placed in the
orders
table.
Display the
productName
of all products in theproducts
table whereproductLine
is 'Classic Cars'.
Find the
customerName
of all customers whosecreditLimit
is greater than 50,000.
Fetch all products that have a
quantityInStock
between 10 and 100.
Display the
employeeNumber
andfirstName
of 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 š§āš»
Top comments (2)
.
dev.to/hanzla-baig/winterland-a-be...