Hi! I have a complex SQL select query which I execute via %ResultSet. It also includes a UNION. The select statement within the union should only be done when an external parameter is set, and I'm not sure of way of doing that within SQL, other than something like
SELECT FOO FROM BAR
WHERE (some conditions)
UNION
SELECT FOO2 FROM BAR2
WHERE :doUnion = 1 AND (some conditions)
...this works, but I don't think it's particularly optimal as I believe it will still execute the second SELECT regardless of :doUnion. It's also sort of hard to read...