Unit 2, lesson 7 · COUNT
Counting rows with COUNT
How many are on sale?
COUNT turns many rows into one number. COUNT(*) counts rows, whatever they hold. COUNT(column) counts only the rows where that column has a value, skipping NULLs. Either way, the whole table becomes a single row.
SELECT COUNT(*) AS customers
FROM customers;Your task
How many products are in the catalog, and how many of them have a discount? Return both numbers in one row.
Tables you will use: products
Try it in your browserFree, no sign-up. Your query is checked as you go.