Each statement should be trivial.
Don't mix multiple operations within one statement.
CASE
or SQL-FunctionsJOIN
and the set operations like UNION
GROUP BY
WHERE
-Conditions, e.g. with sub-queries```sql select * from (select sum(.... from ( select ... from ( select ... from dbTabXY where x = 42 ) left outer join (select ... from dbTabAB where z = 'C' ) on ) where y = '0815' group by abc ) ``` </div><div> ```sql tabVar1 = select ... from dbTabAB: tabVar2 = select ... from dbTabXY where x = 42; tabVar3 = select ... from :tabVar2 left outer join :tabVar1 on ... ; tabVar4 = select sum(.... from :tabVar3 where x = 42 group by abc select ... from :tabVar4; ```