postgres group by vs distinct code example Example: postgres count distinct SELECT COUNT(DISTINCT column) FROM table_name WHERE condition;