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

70+ SQL Interview Question with Sample Data

The document contains a comprehensive list of over 70 SQL interview questions designed for data analysts. It covers various SQL topics such as retrieving salary information, handling duplicates, and querying employee data based on different criteria. The questions are structured to assess a candidate's proficiency in SQL and data manipulation skills.

Uploaded by

vlmohammedadnan9
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

70+ SQL Interview Question with Sample Data

The document contains a comprehensive list of over 70 SQL interview questions designed for data analysts. It covers various SQL topics such as retrieving salary information, handling duplicates, and querying employee data based on different criteria. The questions are structured to assess a candidate's proficiency in SQL and data manipulation skills.

Uploaded by

vlmohammedadnan9
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Sajid Shaikh

Data Analyst

70+ SQL
INTERVIEW
QUESTIONS
Sample Schema:

Sajid Shaikh
Data Analyst
Sample Dataset:

Sajid Shaikh
Data Analyst
Questions:
How to retrieve the second-highest salary of an employee?
How to get the nth highest salary?
How do you fetch all employees whose salary is greater than the
average salary?
Write a query to display the current date and time
How to find duplicate records in a table?
How can you delete duplicate rows?
How to get the common records from two tables?
How to retrieve the last 10 records from a table?
How do you fetch the top 5 employees with the highest salaries?
How to calculate the total salary of all employees?
How to write a query to find all employees who joined in the year 2020?
Write a query to find employees whose name starts with 'A'
How can you find the employees who do not have a manager?
How to find the department with the highest number of employees?
How to get the count of employees in each department?
Write a query to fetch employees having the highest salary in each
department
How to write a query to update the salary of all employees by 10%?
How can you find employees whose salary is between 50,000 and
1,00,000?
How to find the youngest employee in the organization?
How to fetch the first and last record from a table?

Sajid Shaikh
Data Analyst
Questions:
Write a query to find all employees who report to a specific manager
How can you find the total number of departments in the company?
How to find the department with the lowest average salary?
How to delete all employees from a department in one query?
How to display all employees who have been in the company for more
than 5 years?
How to find the second-largest value from a table?
How to write a query to remove all records from a table but keep the
table structure?
Write a query to get all employee records in XML format
How to get the current month's name?
How to convert a string to lowercase?
How to find all employees who do not have any subordinates?
Write a query to calculate the total sales per customer in a sales table
How to write a query to check if a table is empty?
How to find the second highest salary for each department?
Write a query to fetch employees whose salary is a multiple of 10,000
How to fetch records where a column has null values?
How to write a query to find the total number of employees in each job
title?
Write a query to fetch all employees whose names end with 'n'
How to find all employees who work in both departments 101 and 102?
Write a query to fetch the details of employees with the same salary

Sajid Shaikh
Data Analyst
Questions:
How to update salaries of employees based on their department?
How to write a query to list all employees without a department?
Write a query to find the maximum salary and minimum salary in each
department
How to list all employees hired in the last 6 months?
Write a query to display department-wise total and average salary
How to find employees who joined the company in the same month
and year as their manager?
Write a query to count the number of employees whose names start
and end with the same letter
How to retrieve employee names and salaries in a single string?
How to find employees whose salary is higher than their manager's
salary?
Write a query to get employees who belong to departments with less
than 3 employees
How to write a query to find employees with the same first name?
How to write a query to delete employees who have been in the
company for more than 15 years?
Write a query to list all employees working under the same manager
How to find the top 3 highest-paid employees in each department?
Write a query to list all employees with more than 5 years of experience
in each department

Sajid Shaikh
Data Analyst
Questions:
How to list all employees in departments that have not hired anyone in
the past 2 years?
Write a query to find all employees who earn more than the average
salary of their department
How to list all managers who have more than 5 subordinates?
Write a query to display employee names and hire dates in the format
"Name - MM/DD/YYYY"
How to find employees whose salary is in the top 10%?
Write a query to display employees grouped by their age brackets (e.g.,
20-30, 31-40, etc.)
How to find the average salary of the top 5 highest-paid employees in
each department?
How to calculate the percentage of employees in each department?
Write a query to find all employees whose email contains the domain
'@example.com'
How to retrieve the year-to-date sales for each customer?
Write a query to display the hire date and day of the week for each
employee
How to find all employees who are older than 30 years?
Write a query to display employees grouped by their salary range (e.g.,
0-20K, 20K-50K)
How to list all employees who do not have a bonus?
Write a query to display the highest, lowest, and average salary for
each job role

Sajid Shaikh
Data Analyst

You might also like