replace cell null for 0

  • guys

    I have a query that returno value null when tha condition not validates.

    select prod.*, B.Qtd as Qtd from ([select modelo, classe from tabela group by modelo, classe] AS prod

    LEFT JOIN [select modelo, Count(modelo) AS Qtd from tabela where tipo ='A']. AS B ON prod.modelo = B.modelo)

    How Can I replace cell null for 0 using sql?

    Tks!

    Ayres

  • Hi,

    I think you should be able to use an IIF statement in you SELECT. Something like this:

    IIF(B.Qtd IS NULL, 0, ,B.Qtd) AS Qtd

    HTH,



    Ade

    A Freudian Slip is when you say one thing and mean your mother.
    For detail-enriched answers, ask detail-enriched questions...[/url]

  • you can use the NZ function in MS access

    Nz ( YourVariable, [ value_if_null ] )

    or

    Nz (YourVariable)

    will return 0 or empty string if variable is null

  • Gooa idea 🙂

    this is working

    tks!

    but a saw other situation...

    Is possible have two condition in the IIF ?

  • You'd have to nest your IIF statements like this:

    IIF(.., .., IIF(.., .., ..))



    Ade

    A Freudian Slip is when you say one thing and mean your mother.
    For detail-enriched answers, ask detail-enriched questions...[/url]

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply