Counting Rows with COUNT
COUNT is an aggregate function that counts rows. It's one of the most commonly used functions in SQL.
COUNT Syntax
-- Count all rows
SELECT COUNT(*) FROM table_name;
-- Count non-NULL values in a column
SELECT COUNT(column_name) FROM table_name;
New Tables Available
Starting from this lesson, you have access to more tables:
- users - User accounts
- categories - Product categories
- products - Products with prices and stock
Explore the schema panel on the left to see all columns!
Exercises
Loading exercise...
Loading exercise...
Loading exercise...
Loading exercise...
Loading exercise...
COUNT(*) vs COUNT(column)
COUNT(*)counts all rows, including those with NULL valuesCOUNT(column)counts only non-NULL values in that column
Free Practice
Loading SQL editor...
Try:
- Count products in different categories
- Count products within a price range
- Count products with stock below a threshold
التالي · الدرس 14 من 27
SUM and AVG Functions
قراءة 1 دقيقة
أنهيت 13 من 27 درسًا

اسأل Byte عن هذا الدرس
محادثة خاصة حول هذا الدرس. قرأ Byte الدرس كاملًا، ويجيب خلال ثوانٍ، ويُظهر القسم الذي تأتي منه كل إجابة. يمكنك السؤال بأي لغة.
الأسئلة والأجوبة
أسئلة عامة حول هذا الدرس. يجيب AI Tutor فورًا بلغتك، ويراجع فريق FreeAcademy الإجابات، ويمكن لكل المتعلمين قراءتها.

