Let's assume you have very simple table with users:
# \d users
Table "public.users"
Column | Type | Modifiers
-----------+---------+----------------------------------------------------
id | integer | not null default nextval('users_id_seq'::regclass)
username | text | not null
is_active | boolean | not null default true
Indexes:
"users_pkey" PRIMARY KEY, btree (id)
"users_username_key" UNIQUE, btree (username)And you'd like to count all users, and know how many of them are active …
Continue reading Tips N' Tricks – count of all and just some