none
Convert PostgreSQL To MS SQL RRS feed

  • Question

  • Hello - I am working on converting a PostgreSQL query to ms sql.  I am struggling On converting this case statement.  How would this case statement go in MS SQL?

    SUM(case ri.stp when true then Round(salami.amount,2) else null end)

    Thursday, January 9, 2020 2:06 PM

Answers

  • It's nearly the same, but SQL Server don't know true/false but 1/0 =>

    SUM(case ri.stp when 1 then Round(salami.amount,2) else null end)


    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    • Marked as answer by IndigoMontoya Thursday, January 9, 2020 2:13 PM
    Thursday, January 9, 2020 2:09 PM

All replies

  • It's nearly the same, but SQL Server don't know true/false but 1/0 =>

    SUM(case ri.stp when 1 then Round(salami.amount,2) else null end)


    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    • Marked as answer by IndigoMontoya Thursday, January 9, 2020 2:13 PM
    Thursday, January 9, 2020 2:09 PM
  • SUM(case ri.stp when 'true' then Round(salami.amount,2) else null end)
    Thursday, January 9, 2020 2:23 PM
    Moderator