On Tue, Nov 16, 2010 at 11:32 AM, Alexander Farber <alexander.farber@xxxxxxxxx> wrote: > sum(case when good then 1 else 0 end) as good, > sum(case when not good then 1 else 0 end) as "not good", > sum(case when fair then 1 else 0 end) as fair, > sum(case when not fair then 1 else 0 end) as "not fair", > sum(case when nice then 1 else 0 end) as nice, > sum(case when not nice then 1 else 0 end) as "not nice" > from public.pref_rep; Here is one slightly more compact. # select COUNT(NULLIF( good, FALSE)) as good, COUNT(NULLIF( good, TRUE)) as "not good", COUNT(NULLIF( fair, FALSE)) as fair, COUNT(NULLIF( fair, TRUE)) as "not fair", COUNT(NULLIF( nice, FALSE)) as nice, COUNT(NULLIF( nice, TRUE)) as "not nice", from public.pref_rep; -- Regards, Richard Broersma Jr. Visit the Los Angeles PostgreSQL Users Group (LAPUG) http://pugs.postgresql.org/lapug -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general