Académique Documents
Professionnel Documents
Culture Documents
COUNT()
SELECT COUNT(*)
Calculate how many rows are in the fake_apps table
FROM fake_apps;
SUM()
SELECT SUM(downloads)
Calculate the sum of all the values in the downloads
FROM fake_apps; column
MAX()
SELECT MAX(downloads)
Return the highest value in the downloads column
FROM fake_apps;
MIN()
SELECT MIN(downloads)
Return the lowest value in the downloads column
FROM fake_apps;
AVG()
SELECT AVG(price)
Calculate the average value of the price column
FROM fake_apps;
GROUP BY
SELECT category, SUM (downloads)
Calculate the total number of downloads for each
FROM fake_apps
category
GROUP BY category;
GROUP BY
SELECT category, SUM(downloads)
The reference number 1 refers to the first selected
FROM fake_apps
column (category)
GROUP BY 1;
HAVING
SELECT category, SUM(downloads)
FROM fake_apps WHERE can not be used with aggregate functions
GROUP BY category
HAVING is used to filter groups
HAVING SUM(downloads) > 5;
Learn SQL from Scratch
Review
SELECT category, SUM(downloads)
FROM fake_apps 1.SELECT as many columns as you want