Report Offensive Message

A quibble
SELECT 'BOOKS' AS Genre, ''
should be
Null cast as int, as if you pull this resultset in ItemCount will be a varchar.
Or you could make it the last line and not need the cast, geiven you replace '' with a null.

Presumably this is a one off as this is an inflatable dartboard solution
Denormalising with a Genres table with a displayorder column, and replacing Count(*) with Count(Category) , would make it a simple join and aggregate and cope with new categories, and reordering without having to find an rewrite the sql.
Posted by Tony Hopkinson
Updated - 29th Jul 2011