Database_operator
Database_operator

Reputation: 9

PostgreSQL If else

I have issue. I try to do one If-Else, In postgresql. I have 2 colums. "measure" is the measurements INT, and the another column is the "Status" boolean. Both on different table. The query simple, If the measurement more than 100 then change the "Status_SG" true. I lerned Sql but not this deep, and now I stuck.

Checked online many option but non of them works.

Upvotes: 0

Views: 537

Answers (1)

mwalter
mwalter

Reputation: 132

Hope this can solve the problem .

    SELECT 
CASE WHEN (a.intcol > 100) AND b.booleancol THEN 'message1' ELSE 'message2' END
FROM table AS a 
JOIN table2 AS b ON a.id = b.id

Upvotes: 1

Related Questions