This query I used aggregate functions with sub-queries
SELECT
(SELECT MAX(salary) FROM employees) AS Highest,
(SELECT MIN(salary) FROM employees) AS Lowest,
(SELECT COUNT(*) FROM employees) AS Employees,
(SELECT SUM(salary) FROM employees) AS Total
FROM dual
FROM dual
Let us look at this with sub-queries at both the column level
and the CASE level. The following is the query:
SELECT
Employee_id, First_Name,
Salary AS salary,
ROUND((salary -(SELECT AVG(salary) FROM employees)),2) AS
avgcompare,
CASE
WHEN salary >= (SELECT AVG(salary) FROM employees) THEN
‘HIGH’
ELSE ‘LOW’
END AS paying
FROM employees
FROM employees