SQL Beginner Interview Questions-Writing Queries

The Test Lead
2 min readNov 20, 2023

These queries cover a range of basic operations and can serve as a good starting point for entry-level interview preparation. Make sure to understand the logic behind each query and practice writing them on your own.

These are tables you can use as a reference

Retrieve all columns from a table named Customers.

SELECT * FROM Customers;

Retrieve the names and ages of all customers.

SELECT Name, Age FROM Customers;

Find the total number of customers.

SELECT COUNT(*) FROM Customers;

Retrieve unique cities from the Customers table

SELECT DISTINCT City FROM Customers;

Retrieve customers from a specific city (e.g., ‘New York’).

SELECT * FROM Customers WHERE City = ‘New York’;

Retrieve customers aged 30 or older.

SELECT * FROM Customers WHERE Age >= 30;

Retrieve customers sorted by name in ascending order.

SELECT * FROM Customers ORDER BY Name ASC;

Retrieve the names and emails of customers whose names start with ‘J’.

SELECT Name, Email FROM Customers WHERE Name LIKE ‘J%’;

Update the city of a customer with CustomerID 101 to ‘Los Angeles’.

UPDATE Customers SET City = ‘Los Angeles’ WHERE CustomerID = 101;

Insert a new customer with the name ‘John Doe’ and age 25 from the city ‘Chicago’.

INSERT INTO Customers (Name, Age, City) VALUES (‘John Doe’, 25, ‘Chicago’);

Delete a customer with CustomerID 102.

DELETE FROM Customers WHERE CustomerID = 102;

Retrieve the highest salary from the Employees table.

SELECT MAX(Salary) FROM Employees;

Retrieve the average age of customers.

SELECT AVG(Age) FROM Customers;

Retrieve the names of customers along with their corresponding cities.

SELECT Name, City FROM Customers;

Retrieve the first 5 records from the Orders table.

SELECT * FROM Orders LIMIT 5;

--

--

The Test Lead

SDET at fintech company in NYC. Visit personal page http://thetestinglead.com// Twitter @juss_bailey Youtube @The Test Lead