EasyBasic SELECT

Show total, average salary across entire company

The query

SQL
SELECT
  COUNT(*) AS total_employees,
  SUM(salary) AS total_payroll,
  ROUND(AVG(salary), 2) AS avg_salary,
  MAX(salary) AS highest_salary,
  MIN(salary) AS lowest_salary,
  MAX(salary) - MIN(salary) AS salary_range
FROM employees
WHERE status = 'active';
Tested against PostgreSQL 16

Note

All aggregate functions in one query for a complete salary overview.

Tables referenced