Thursday, May 29, 2008

Query to display duplicate values

This query will display how many times a certain value occurs in a table.

SELECT a, COUNT(a) AS numoccurences FROM table WHERE a IS NOT NULL
GROUP BY a;

It's useful to create a view with this query and then use the values in other queries.

No comments: