Nidhi Gupta
4 min readMar 18, 2023

--

SQL Interview Questions

In this article, I will be sharing a few SQL interview questions which are commonly asked in SQL interviews.

Script for table creation

TABLE:-
CREATE TABLE Employee
(ID INT PRIMARY KEY,
Name VARCHAR(50) NULL,
RoleName VARCHAR(10) NULL,
Salary NUMERIC(18,2) NULL
);

DATA:-
INSERT INTO Employee(name,rolename,salary)VALUES
( ‘Alex’, ‘SuperAdmin’, 90000 ),
( ‘Thomas’, ‘Admin’, 80000 ),
( ‘Peter’, ‘SuperAdmin’, 95000 ),
( ‘Sid’, ‘SuperAdmin’, 70000 ),
( ‘Maria’, ‘Admin’, 60000 ),
( ‘Andrew’, ‘Manager’, 50000 ),
( ‘Fedric’, ‘SuperAdmin’, 45000 ),
( ‘Anton’, ‘Supervisor’, 93000 ),
( ‘Mandy’, ‘Manager’, 30000 );

select * from employee

Problem Statement: Write an SQL query to print the details of an employee whose salary is greater than the average salary in their role name.

Solution:

Using SubQuery

select * from employee e where e.salary > (
select avg(salary) from employee
where…

--

--

Nidhi Gupta

Azure Data Engineer 👨‍💻.Heading towards cloud technologies expertise✌️.