jeudi 15 septembre 2016

show '-' instead of 0 in sql select

I want to get '-' instead of 0 when the value i am selecting is equal to 0.

Qa01 field is a string. (i have to cast it to Integer for the SUM fonction)

here i tried this :

SELECT [Code article],Division,count(LigneFab),
IIF(sum(cast(Qa01 as int))='0','-',sum(cast(Qa01 as int))) as qa01
from dbo.PDP where [Code article] = '10000100510' and Division = '1000'
group by [Code article],Division

If Qa01 value is '10' it's displaying '10' but if the value is '0', it's displaying '0' instead of '-' so my query is not working..

Is there a way to display '-' instead of '0' ?

Thanks for the help

Aucun commentaire:

Enregistrer un commentaire