sql server - Include A 0 Count if null or blank in pivot -
i need show data each part, , query working...almost. syntax
select * ( select item [item], count(sold) [count], storename saleinfo group item, storename ) first pivot ( count([count]) item in ([brake pads], [rotors],[shoes],[drums] ) piv
now issue having if count of 0 returned item omitted results. meaning if 0 brake pads sold brake pads not dispalyed in result set. how can have dispaly item if count returned 0?
you use isnull or coalesce convert null 0
:
select isnull([brake pads], 0) [brake pads], isnull([rotors], 0) [rotors], isnull([shoes], 0) [shoes], isnull([drums], 0) [drums] ( ...
Comments
Post a Comment