Hi Anu,
the first WHEN in a CASE which evaluates to TRUE will be used, it's not doing a kind of best-match.
The rule of thumb is to define the most restrictive condition first.
You could rewrite it to:
CASE
WHEN TYPE_CD IN ('01','02') THEN 1
WHEN TYPE_cD IN ('03') AND STS_CD<>'N' THEN 1
ELSE 0
END as CNT
or
CASE
WHEN TYPE_CD IN ('01','02')
OR (TYPE_cD IN ('03') AND STS_CD<>'N') THEN 1
ELSE 0
END as CNT
Hi Anu,
the first WHEN in a CASE which evaluates to TRUE will be used, it's not doing a kind of best-match.
The rule of thumb is to define the most restrictive condition first.
You could rewrite it to: