sahil
sahil

Reputation: 121

Case expression in postgres

I have data in below table format.

id qid oid
1 101 10
2 101 20
3 103 10
4 102 20
5 101 10

case expression :

case when (qid=101 and oid=10) and (qid=103 and oid=10) then 1 else end as output

If above case condition match then output should be below.

id qid oid output
1 101 10 1
3 103 10 1
5 101 10 1

Upvotes: 0

Views: 146

Answers (1)

peter
peter

Reputation: 9

Try writing the case statement in more than 1 LINe i.e

CASE 
    WHEN (qid=101 and oid=10) THEN 1
    WHEN  (qid=103 and oid=10) then 1 
ELSE end as output

Upvotes: 1

Related Questions