SQL Exercise:
Write Query to:
- Find all customers with the last name “Singh”.
- Retrieve customers whose email address contains the word “kumar”.
- Retrieve customers living in cities that end with “pur”.
Table Creation Script:
CREATE TABLE Customers ( CustomerID INT PRIMARY KEY, Name VARCHAR(50), City VARCHAR(50), Email VARCHAR(100) );
Insert Data into Customers Table:
Solution:
1. Customers with the last name ‘Singh’
SELECT * FROM customers WHERE name LIKE '%singh'

Explanation:
Name LIKE ‘%Singh’:
- %Singh matches any string ending with “Singh”.
- This will match “Sneha Singh”.
2. Customers whose email contains the word ‘kumar’
SELECT * FROM Customers WHERE Email LIKE '%kumar%';

Explanation:
Email LIKE ‘%kumar%’:
- %kumar% matches any string containing “kumar”.
- This will match rajesh.kumar@gmail.com.
3. Customers living in cities ending with ‘pur’
SELECT * FROM Customers
WHERE City LIKE '%pur';

Explanation:
City LIKE ‘%pur’:
- %pur matches any string ending with “pur”.
- This will match cities like “Jaipur”.
![]()
