Exercise 1 -SQL Fundamentals (SELECT & Filtering Statements)
Exercise 1 -SQL Fundamentals (SELECT & Filtering Statements)
Data Analytics
Database: employees_db
Assume you have a table called employees with the following structure:
Questions
1. SELECT Statement
Write a SQL query to retrieve all columns from the employees table.
Write a SQL query to find all the unique departments in the employees table.
3. ORDER BY Statement
Write a SQL query to retrieve all employees' first and last names, ordered by salary in
descending order.
4. LIMIT Statement
5. WHERE Statement
Write a SQL query to find employees who work in the IT department.
6. AND Statement
Write a SQL query to find employees who work in the Finance department AND have a
salary greater than 58,000.
7. OR Statement
Write a SQL query to find employees who work in the HR department OR the Marketing
department.
8. NOT Statement
Write a SQL query to find employees who do not work in the IT department.
9. IN Statement
Write a SQL query to find employees who are in the HR, IT, or Finance departments.
Write a SQL query to find employees who are in the IT department, have a salary greater
than 50,000, and are located in New York.
Write a SQL query to retrieve the first and last names of employees who work in the
Finance or Marketing department, earn more than 52,000, and order the results by
salary in descending order.
Write a SQL query to find all the unique cities where employees work, excluding those
in the IT and HR departments.
Write a SQL query to retrieve employees who are NOT in the Finance department,
have a salary greater than 50,000, and order the results by hire date in ascending
order.
Write a SQL query to find the first 3 employees who work in either Chicago or Los
Angeles and belong to the IT or Marketing department.