Part 1: SQL Skills You Need to Be a Data Engineer
On this page
Let's begin the actual interview preparation for SQL. I assume you are already familiar with SQL and understand the core concepts. Perhaps you are struggling with confidence for interviews, or you are here to identify what else you might be missing to become a data engineer.
So today, we will explore Part 1 of this post: The Only SQL Skills You Need to Be a Data Engineer | Blog
The best way to learn SQL is through practice. Below, you will find a sample dataset and a list of questions. Make sure not to look at the answers; instead, try solving the questions yourself. You can use the SQL playground for this purpose. at SQL Playground - Practice SQL Online | Noruj
Let's warm up with a 10-question quiz.
Create the Sample Dataset
Create Table
CREATE TABLE employees (
emp_id INT,
emp_name VARCHAR(50),
department VARCHAR(30),
salary INT,
age INT,
joining_date DATE,
city VARCHAR(30)
);Insert Sample Data
INSERT INTO employees VALUES
(1, 'Alice', 'IT', 90000, 30, '2019-03-10', 'Bangalore'),
(2, 'Bob', 'IT', 75000, 28, '2020-07-15', 'Hyderabad'),
(3, 'Charlie', 'HR', 60000, 35, '2018-01-20', 'Delhi'),
(4, 'David', 'HR', 65000, 32, '2019-11-01', 'Mumbai'),
(5, 'Eva', 'Finance',85000, 29, '2021-06-18', 'Bangalore'),
(6, 'Frank', 'Finance',95000, 41, '2017-09-23', 'Delhi'),
(7, 'Grace', 'IT', 105000, 38, '2016-05-30', 'Chennai'),
(8, 'Helen', 'HR', 58000, 26, '2022-02-14', 'Hyderabad'),
(9, 'Ian', 'Finance',72000, 34, '2020-08-09', 'Mumbai'),
(10,'Jane', 'IT', 68000, 27, '2021-12-01', 'Bangalore'),
(11,'Kevin', 'IT', 80000, 31, '2019-04-17', 'Delhi'),
(12,'Laura', 'HR', 62000, 36, '2018-06-25', 'Chennai'),
(13,'Mike', 'Finance',78000, 33, '2019-10-10', 'Hyderabad'),
(14,'Nina', 'IT', 72000, 29, '2022-01-05', 'Mumbai'),
(15,'Oscar', 'HR', 59000, 28, '2021-03-19', 'Bangalore');Level 1: Basic Retrieval (Warm-up)
Display all employees.
SELECT * FROM employees;Display emp_name, department, salary.
SELECT emp_name, department, salary FROM employees;Show employees working in IT department.
SELECT * FROM employees WHERE department='IT';Show employees whose salary is greater than 80,000.
SELECT * FROM employees WHERE salary > 80000;List employees sorted by salary (highest first).
SELECT * FROM employees ORDER BY salary DESC;Level 2: Filtering Logic (AND / OR / IN / BETWEEN)
Employees from IT department earning more than 70,000.
SELECT * FROM employees WHERE department = 'IT' AND salary > 70000;Employees from IT or HR departments.
SELECT * FROM employees WHERE department IN ('IT','HR');Employees whose salary is between 60,000 and 90,000.
SELECT * FROM employees WHERE salary > 60000 AND salary < 90000;Employees living in Bangalore or Hyderabad.
SELECT * FROM employees WHERE city = 'Bangalore' OR city = 'Hyderabad';Employees older than 30 and salary above 75,000.
SELECT * FROM employees WHERE age > 30 AND salary > 75000;Level 3: Aggregations
Total number of employees.
SELECT count(*) AS total_employees FROM employees;Average salary of all employees.
SELECT ROUND(AVG(salary)) AS avg_salary FROM employees;Highest salary in the company.
SELECT MAX(salary) AS highest_salary FROM employees;Lowest salary in HR department.
SELECT MIN(salary) AS lowest_salary FROM employees WHERE department = 'HR';Total salary paid to Finance department.
SELECT SUM(salary) AS total_salary FROM employees WHERE department = 'Finance';Level 4: GROUP BY (Very Important)
Number of employees in each department.
SELECT department, count(*) as employees FROM employees GROUP BY department;Average salary per department.
SELECT department, ROUND(AVG(salary)) AS avg_salary FROM employees GROUP BY department;Maximum salary per department.
SELECT department, MAX(salary) AS max_salary from employees GROUP BY department;Number of employees per city.
SELECT city, count(*) AS employees FROM employees GROUP BY city;Average age per department.
SELECT department, ROUND(AVG(age)) AS avg_age FROM employees GROUP BY department;Level 5: HAVING (Interview Favorite)
Departments having more than 4 employees.
SELECT department, COUNT(*) AS total_employees
FROM employees
GROUP BY department
Having count(*) > 4; Departments where average salary is greater than 75,000.
SELECT department, ROUND(AVG(salary)) AS avg_salary
FROM employees
GROUP BY department
HAVING avg(salary) > 75000;Cities having more than 2 employees.
SELECT city, count(*) AS num_employees
FROM employees
GROUP BY city
HAVING count(*) > 2;Departments where minimum salary is less than 60,000.
SELECT department, min(salary) AS min_salary
FROM employees
GROUP BY department
HAVING min(salary) < 60000;Departments with total salary payout greater than 300,000.
SELECT department, sum(salary) AS total_payout
FROM employees
GROUP BY department
HAVING sum(salary) > 300000;Level 6: Combined / Real Interview Questions
Note: dont use window functions are sub-queries.
Top 3 highest paid employees.
SELECT DISTINCT(salary)
FROM employees
ORDER BY salary
DESC limit 3;Top 2 departments by average salary.
SELECT round(avg(salary)) AS avg_salary
FROM employees
GROUP BY department limit 2;Departments with avg salary > 70,000, sorted descending.
SELECT department, ROUND(AVG(salary)) AS avg_salary
FROM employees
GROUP BY department
HAVING avg(salary) > 70000
ORDER BY avg_salary desc;Count of employees joined after 2020 per department.
SELECT department, COUNT(*) AS employees
FROM employees
WHERE joining_date > DATE('2020-01-01') GROUP BY department;City-wise employee count where count > 2, sorted by count.
SELECT city, count(*) as num_employees
FROM employees
GROUP By city
HAVING count(*)> 2
ORDER BY num_employees DESC;How to Use This for Interview Confidence
Do this daily drill:
Pick 5 questions
Write SQL without looking
Run query
Explain aloud:
Why WHERE is used
Why GROUP BY is needed
Why HAVING is correct
If you can explain, you will clear interviews.
Be Honest
If you can solve all 30 correctly, you are:
Strong enough for SQL screening rounds
Ready to move to joins and window functions
Already ahead of many “data engineer” applicants
Next Step
I hope you have completed all the questions and taken the quiz. If you feel comfortable, please leave a comment with your status. Was this difficult or easy for you?
i will see you in PART 2. ✌️