Aug 15, 2008

group by and having options

The having command with the group by command is very useful when wanting specific rows, based on the group by construct to be removed.

For example, to work what values of a unique key is forcing the create unique index type command to fail, use something like:

select column, count(*) from table
group by column
having count(*) > 1;

will cause only occurances to display that have more than two rows, i.e.: the key values that is causing the create unique index to fail.