🔔 Subscribe for more SQL & PostgreSQL tutorials: [Your Channel Link]
Title: PostgreSQL COUNT Tutorial — COUNT(*), COUNT(column), COUNT(DISTINCT) & FILTER
In this video you'll learn:
• The difference between COUNT(*) and COUNT(column)
• When to use COUNT(DISTINCT ...)
• How to do conditional counts with FILTER and CASE
• Real examples and output you can copy-paste
Example SQL queries shown:
-- Count all rows
SELECT COUNT(*) FROM employees;
-- Count non-null values in a column
SELECT COUNT(email) FROM employees;
-- Count unique emails
SELECT COUNT(DISTINCT email) FROM employees;
-- Conditional count using FILTER (Postgres)
SELECT
COUNT(*) FILTER (WHERE status = 'active') AS active_count,
COUNT(*) FILTER (WHERE status = 'inactive') AS inactive_count
FROM users;
-- Conditional count using SUM + CASE
SELECT
SUM(CASE WHEN status = 'active' THEN 1 ELSE 0 END) AS active_count
FROM users;
Want the example dataset and SQL file? Download: [add your link here]
👨💻 Who is this for?
Beginners to intermediate devs, DBAs, data analysts — anyone using PostgreSQL or learning SQL.
👍 If the video helped — like, comment your questions, and SUBSCRIBE for more PostgreSQL/SQL content.
Hashtags: #PostgreSQL #SQL #Database #Count #Tutorial #Data
Music / Assets: [list your credits or “None”]
— End of Description —
#PostgreSQL #SQL #Database #COUNT #LearnSQL