I am trying to write a case to get a specific date value in a field, but keep getting errors.
My case looks like this:
CASE WHEN TEP ='QC' AND (CHECKFLOW IN ('Process') THEN DATE ELSE 0 END AS QCStopTime
My SQL example:
SELECTDISTINCT ID, STEP ,FLOW, DATE,
CASEWHEN STEP ='QC 'AND (CHECKFLOW IN ('Process’)) THEN DATE ELSE 0 END AS QCStopTime
fromMyTable
where ID='ABC123'
AND MESSAGE =‘COMPLETED’
AND ACTIONTIME > 0
Desired data:
Each time I write the query, I get an error that states:
DB2 Database Error: ERROR [42804] [IBM][DB2/LINUXX8664] SQL0581N The data types of the result-expressions of a CASE expression or DECODE function are not compatible
Are cases not allowed or able to reference a field?
Thoughts on how to write this better?
Thanks in advance for your help.