eolas/Databases/SQL/11_Aggregate_functions.md
2022-08-05 20:30:04 +01:00

454 B

tags
Programming_Languages
Databases
sql

SQL Aggregate functions

Count return with custom variable

SELECT COUNT(*) AS total_sales
FROM SALES

Sum

SELECT SUM(price) as total_value
FROM sales

Average

SELECT AVG(price) as average_income
FROM sales

Applying aggregate function with sorting applied

SELECT COUNT(*) AS total_sales
FROM sales
GROUP BY employee_id