Hi,
First you can find the syntax/usage of CASE expression from Expressions - SAP HANA SQL and System Views Reference - SAP Library Don't know what d means in your query, e.g., d.kunnr, d.lifnr and d.parnr, since you have only a and b in your FROM clause.
Best regards,
Wenjun