Subject select expressions vs. select statements
Author Ann W. Harrison
A customer converting from Oracle has a (horrible,
massive, badly performing) query that includes
something like this:

select x from foo
where exists (select 1 from foo where x > 10
union
select 1 from foo where x < 10)

(I know that's an idiotic query - it's the syntax
I'm worried about at the moment.)

The DSQL parser spits up when it encounters the
union, just as if it thought that you couldn't
have a UNION clause in a subquery. My recent
web surf has failed to enlighten me, and I'm quite
sure I'm confusing the rules about updateable views
with the rules about subqueries.

Does anyone know whether union clauses are allowed
in subqueries according to the SQL-99 or SQL-92
standards, any level? Not that it's going to do any
great good. Even if we took the syntax, we'd more
than likely create an access plan that would take
months to execute.

Cheers,

Ann