Re: Need help with sql

From: MK <imanoj_at_yahoo.com>
Date: 6 Dec 2001 17:57:57 -0800
Message-ID: <997a817f.0112061757.65c6a609_at_posting.google.com>


xmy009_at_163.net (xmy) wrote in message news:<440264b2.0112060636.4d11f04f_at_posting.google.com>...
> Hi folks,
>
> I have another question for
> you. I have written a query using UNION operator. I have tested these
> two
> queries seprately and they work well, but when I use the UNION an
> error
> appears telling me that UNION is an unknown command.. strange!
>
> here is my query :
>
> SELECT input_date, SUM(totbo) as USCO_TOTBO, SUM (xci_count) as
> XCI_TOTBO
> FROM
> (SELECT input_date, totbo, 0 as xci_count
> FROM uscobosum
> WHERE input_date >= ADD_MONTHS(sysdate,-24) and
> (TO_CHAR(input_date,'DAY') like 'M%')
>
> UNION
>
> SELECT input_date,0 as totbo, sum(totbo)
> FROM xci_bo
> WHERE input_date >=ADD_MONTHS(sysdate,-24)
> GROUP BY input_date
> )
> GROUP BY input_date;
>
> think you help me.

I had the similar problem long ago and after sweating for many hours , by luck, I removed the blank line before and after word UNION and it worked. It's a mystery but it worked.

Before

SELECT ... UNION SELECT ... After

SELECT ....
UNION
SELECT .... Received on Fri Dec 07 2001 - 02:57:57 CET

Original text of this message