🔍 Q1. Find the total number of employees in the company.
🗂️ Table: employees(id, name)
✅ Answer:
SELECT COUNT(*) AS total_employees
FROM employees;
🔍 Q2. Calculate the average salary of all employees.
🗂️ Table: employees(name, salary)
✅ Answer:
SELECT AVG(salary) AS average_salary
FROM employees;
🔍 Q3. Get the department-wise total salary expense.
🗂️ Table: employees(name, department, salary)
✅ Answer:
SELECT department, SUM(salary) AS total_salary
FROM employees
GROUP BY department;
🔍 Q4. Find the highest salary in each department.
🗂️ Table: employees(name, department, salary)
✅ Answer:
SELECT department, MAX(salary) AS max_salary
FROM employees
GROUP BY department;
🔍 Q5. Count how many employees earn more than 50,000.
🗂️ Table: employees(name, salary)
✅ Answer:
SELECT COUNT(*) AS high_earners
FROM employees
WHERE salary > 50000;
🔍 Q6. Get the minimum salary in the company.
🗂️ Table: employees(salary)
✅ Answer:
SELECT MIN(salary) AS min_salary
FROM employees;
💬 Tap ❤️ for more!
Top comments (0)