Is the number of states 1, 2 and 3 fixed or not?
If it's fixed, a simple Group By associated with a 3 Sum() over 3 Case
statements will do the trick, otherwise it's more complicated; as SQL-Server
doesn't offer a direct support for Pivot transformation.

Signature
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF
> The simple(?) problem is:
>
[quoted text clipped - 21 lines]
>
> Which is the SQL command to do that?, simple or not?