0% found this document useful (0 votes)
16 views

SQL Interview Part 2

This document discusses SQL interview questions and contains examples of SQL queries. It provides 20 questions about retrieving data from an Employees table using SQL commands like SELECT, WHERE, IN, BETWEEN, ORDER BY, LIMIT, COUNT, DISTINCT, AVG, CONCAT, LENGTH, and SUBSTRING. The questions cover topics like filtering records by conditions, sorting, aggregating, and manipulating data. The document encourages following for additional SQL interview questions in part 3 of the series.

Uploaded by

paulwalker84193
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

SQL Interview Part 2

This document discusses SQL interview questions and contains examples of SQL queries. It provides 20 questions about retrieving data from an Employees table using SQL commands like SELECT, WHERE, IN, BETWEEN, ORDER BY, LIMIT, COUNT, DISTINCT, AVG, CONCAT, LENGTH, and SUBSTRING. The questions cover topics like filtering records by conditions, sorting, aggregating, and manipulating data. The document encourages following for additional SQL interview questions in part 3 of the series.

Uploaded by

paulwalker84193
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Anil Patel Architect - Data

Engineering & Analytics


@anilpatel Career Transition Coach

Top 30

SQL Interview Questions

Part - 2
Anil Patel Architect - Data
Engineering & Analytics
@anilpatel Career Transition Coach

Introduction
SQL (Structured Query Language) is a programming language used for managing and
manipulating relational databases. It allows users to interact with databases by performing
tasks like querying data, inserting records, updating information, and deleting entries,
making it essential for handling data effectively in various applications.

Table : Employees

ID Name Department Salary

1. Brayden IT 52000

2. Chris HR 54000

3. Ailani Marketing 65000

4. Dalton Finance 68000

5. Lara IT 46000

6. Anala Finance 71000

7. Marshall HR 42000

8. Ishana Marketing 59000


Anil Patel Architect - Data
Engineering & Analytics
@anilpatel Career Transition Coach

Q11. Retrieve employees whose names start with the


letter 'A'

SELECT *
FROM Employees
WHERE Name LIKE ' A% ' ;

Q12. Retrieve employees with a salary higher than


60000

SELECT *
FROM Employees
WHERE Salary > 60000 ;

Q13. Retrieve employees from the IT or Marketing


Departments

SELECT *
FROM Employees
WHERE Department IN ( ' IT ' , ' Marketing ' ) ;
Anil Patel Architect - Data
Engineering & Analytics
@anilpatel Career Transition Coach

Q14. Retrieve names and salaries of the top 5


employees in the Finance Department

SELECT Name, Salary


FROM Employees
WHERE Department = ' Finance '
ORDER BY Salary DESC Limit 5 ;

Q15. Retrieve employees with a salary between 45000


and 55000

SELECT *
FROM Employees
WHERE Salary BETWEEN 45000 AND 55000 ;

Q16. Count the number of distinct departments in the


Employees Table

SELECT COUNT( DISTINCT Department )


FROM Employees ;
Anil Patel Architect - Data
Engineering & Analytics
@anilpatel Career Transition Coach

Q17. Calculate the average salary of employees in the


HR Department

SELECT AVG( Salary )


FROM Employees
WHERE Department= ' HR ' ;

Q18. Concatenate the Name and Department columns


and rename the result as EmployeeInfo

SELECT CONCAT( Name, ' __ ' , Department )


AS EmployeeInfo
FROM Employees ;

Q19. Retrieve names of employees along with the


length of their names

SELECT Name, LENGTH( Name )


AS NameLength
FROM Employees ;
Anil Patel Architect - Data
Engineering & Analytics
@anilpatel Career Transition Coach

Q20. Retrieve the first three characters of the names of


all employees

SELECT SUBSTRING( Name, 1, 3 )


FROM Employees ;

Don't forget to Follow for Part - 3 !

You might also like