✅ SQL Aggregate Functions Practice Questions with Answers 🧠📊
🔎 Q1. Find the total salary of all employees.
🗂️ Table: "employees(emp_id, name, salary)"
✅ Answer:
SELECT SUM(salary) AS total_salary
FROM employees;
🔎 Q2. Calculate the average salary of employees.
🗂️ Table: "employees(emp_id, name, salary)"
✅ Answer:
SELECT AVG(salary) AS avg_salary
FROM employees;
🔎 Q3. Count total number of employees in the company.
🗂️ Table: "employees(emp_id, name)"
✅ Answer:
SELECT COUNT(*) AS total_employees
FROM employees;
🔎 Q4. Find the highest and lowest salary.
🗂️ Table: "employees(emp_id, name, salary)"
✅ Answer:
SELECT MAX(salary) AS highest_salary,
MIN(salary) AS lowest_salary
FROM employees;
🔎 Q5. Get total salary paid in each department.
🗂️ Table: "employees(emp_id, name, department_id, salary)"
✅ Answer:
SELECT department_id,
SUM(salary) AS total_salary
FROM employees
GROUP BY department_id;
Double Tap ♥️ For More
Post #2607
8K
- ❤ 38