SQL LESSON 10 OF 32

Aggregate your data

COUNT counts, SUM totals, AVG averages, MIN and MAX find extremes. COUNT(*) counts rows; COUNT(column) skips NULL in that column. Most aggregates ignore NULL inputs.

हिन्दी में समझें

COUNT गिनता, SUM जोड़ता, AVG औसत, MIN और MAX सीमाएँ निकालते हैं। COUNT(*) पंक्तियाँ, COUNT(column) गैर-NULL मान गिनता है।

अभ्यास: products से COUNT(*) को total और SUM(price) को total_price दिखाएँ।

Hinglish mein samjhein

COUNT count, SUM total, AVG average, MIN/MAX extremes dete hain. COUNT(*) rows ginta hai; COUNT(column) NULL skip karta hai.

Practice: products se COUNT(*) AS total aur SUM(price) AS total_price lo.

A small SQL example

SELECT COUNT(*) AS products, AVG(price) AS avg_price FROM products;

Examples use the fictional shop database bundled with the SQL playground: customers, products, orders, order_items and employees. The engine is SQLite; other SQL dialects may differ.

Try this example in the SQL playground →

Practise this idea

Return COUNT(*) as total and SUM(price) as total_price from products.

Check answer & explanation
SELECT COUNT(*) AS total, SUM(price) AS total_price FROM products;

COUNT(*) counts all product rows. SUM(price) adds the non-NULL prices into a single total.

Stuck in the course? Choose Check answer for either the challenge or quiz. Read the explanation and continue to the next lesson at your own pace.

Check your understanding

COUNT(column) skips…

  1. NULL values
  2. Zero values
  3. All text
Check the quiz answer

NULL values

COUNT counts, SUM totals, AVG averages, MIN and MAX find extremes. COUNT(*) counts rows; COUNT(column) skips NULL in that column. Most aggregates ignore NULL inputs.

References & corrections

Use the official SQLite documentation for full language rules. Read how these lessons are made and checked. Found a mistake? Report it to Excel Keys with this lesson URL and a reproducible example.

FROM LEARNING TO BUSINESS RESULTS

Need a dashboard for your team?

Excel Keys designs custom Excel and HTML dashboards around your own KPIs and Excel files. They run offline in the browser, so your data stays on your computer.