I have some queries which works correctly in PostgreSQL but I have to use them to make IBM DB2 queries. It seems like "FILTER" doesn't work with DB2.
My PGSQL query :
SELECT CODACT, SUM(CUMCOL) FILTER(WHERE etasup > 20), SUM(CUMCOL)
FROM gesupe WHERE typsup= '1' AND (DATLIV = 20220428 OR DATLIV = 20220429) GROUP BY CODACT
When I use this with DB2 I get this error :
Element '(' not correct. Possible elements : , FROM INTO
CodePudding user response:
In general, it should be possible to rewrite the FILTER into a CASE statement. Something like:
SUM(CASE WHEN etasup > 20 THEN CUMCOL END)