1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] Select with IF statement on postgresql

Discussão em 'Outras Linguagens' iniciado por Stack, Setembro 25, 2021.

  1. Stack

    Stack Membro Participativo

    I have a code like that:

    select
    tbl.person
    ,COUNT(distinct tbl.project)
    ,if (tbl.stage like '%SIGNED%') then sum(tbl.value) else '0' end if as test
    from
    my_table tbl
    group by
    1



    And it returns me that error message:

    SQL Error [42601]: ERROR: syntax error at or near "then"


    I didn't got it. As I saw on documentation, the if statement syntax appears to be used correctly

    Continue reading...

Compartilhe esta Página