Change null values to '0' in a SQL pivot

2

I have something more or less like that

select * from( selcect ...)as pt
pivot(
asc(valor) for desc in 
(
[Deporte y cultura],[Despensa],[Destajo - sueldo],
 [Destajos], etc ...)
) as pvt

So far so good, but I get many results as null from that pivot , could someone tell me how to change them to zero?

    
asked by E.Rawrdríguez.Ophanim 19.09.2018 в 18:59
source

1 answer

1

You can use the ISNULL function like this:

select 
    ISNULL([Deporte y cultura], 0),
    ISNULL([Despensa], 0),
    ISNULL([Destajo - sueldo], 0),
    ISNULL([Destajos], 0) 
from( selcect ...)as pt
pivot(
    asc(valor) for desc in 
    (
        [Deporte y cultura],
        [Despensa],
        [Destajo - sueldo],
        [Destajos],
        etc ...
    )
) as pvt

The same question here .

    
answered by 19.09.2018 / 19:21
source