π 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)