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 |
qidcan't hold a value of 101 AND 103 simultaneously. You need anOR.case when (qid=101 and oid=10) OR (qid=103 and oid=10)qinqidmeans quantum .. so that would explain two states simultaneously :-DCASEstatement in question is equal to this:CASE WHEN (qid = 101 AND qid = 103) AND oid = 10 THEN 1 END. Which means for any one record/row you would needqidto be 101 AND 103 which isn't possible based on your data. You can either use anORor write it in multiple statements like peter suggested.