Archive for the ‘SQL’ Category

The Joys of COUNT

2006.05.10, Wed

COUNT has actually two forms: COUNT(*) counts the number of rows in a table; and COUNT(expr) counts the non-null occurrences of expr. This is very useful for generating reports, e.g.:

SELECT COUNT(*) AS ‘Total’, COUNT(ID_winner) AS ‘Claimed’