Re: union subqueries in "from" clause (IDS 9.4)
Posted in 2005
Topics: SQL Development & Query Writing, Versions, Editions & End-of-Life
I think this select will do the same thing ...
SELECT q, sum(v)
FROM utest
WHERE w='a'
OR w='b'
GROUP BY q;
I think you're right - maybe I chose a poor example. Perhaps a better
one....
Forgetting about the V column, suppose I just wanted to do the following:
select q, sum(r) from (
select q,1 r from utest where w='a' union all
select q,2 r from utest where w='b'
) group by q;
In any case, my question is less one of "is there some way to do this that
doesn't involve a union subquery?"...
...and more one of "what is the correct syntax for constructing a query that
uses a union in the from clause?"
"scottishpoet" <dryburghj@yahoo.com> wrote in message
news:1115998903.781192.98680@g44g2000cwa.googlegroups.com...
> I think this select will do the same thing ...
>
> SELECT q, sum(v)
> FROM utest
> WHERE w='a'
> OR w='b'
> GROUP BY q;>