Materialize hint required for complex SELECT in 12c
During migration from Oracle 11gR2 to 12c we encountered a weird error. We had a very complex select, that used WITH clauses, some with GROUP BY. It works in 11g, but with 12c it fails with:
ORA-00979: not a GROUP BY expression
Apparently something has changed. We have not yet found the root cause of the issue, but if we add
/*+ materialize */ to the selects in the WITH clauses it works!
If the query is simplified a bit the hint is not required, even though it still has the same GROUP BY clauses. Smells like a bug.
EDIT: reported to Oracle as Bug 20887136 – ORA-00979 AFTER UPGRADE TO 18.104.22.168.