From: Himansu on
Thanks, Plamen.


"Plamen Ratchev" <Plamen(a)SQLStudio.com> wrote in message
news:d02ku597ev0oj1d0ep56434vtc1adf4obr(a)4ax.com...
> Simply change the SUM to use 1 instead of value:
>
> SELECT product,
> SUM(CASE WHEN value BETWEEN 0 AND 2 THEN 1 ELSE 0 END) AS
> total0_2,
> SUM(CASE WHEN value BETWEEN 3 AND 5 THEN 1 ELSE 0 END) AS
> total3_5,
> SUM(CASE WHEN value BETWEEN 6 AND 9 THEN 1 ELSE 0 END) AS
> total6_7
> FROM Products AS P
> UNPIVOT
> (value FOR product IN (ProductA,
> ProductB,
> ProductC,
> ProductD,
> ProductE)) AS U
> GROUP BY product;
>
> --
> Plamen Ratchev
> http://www.SQLStudio.com