September 9, 2005 at 1:58 am
My UNION (shown below) works. It gives me the right results.
(SELECT Table1.Invoice_No, Table1.Product_Name, Table1.Qty*-1 AS Qty
FROM Table1
WHERE Table1.Movement='Out')
UNION
(SELECT Table1.Invoice_No, Table1.Product_Name, Table1.Qty
FROM Table1
WHERE Table1.Movement='In')
However, it's when I want to Select something from the query above that's when I get the error message. I was wondering if it was allowed. Thanks again.
I am getting a "Incorrect syntax near the keyword 'UNION'." error message from the folowing.
SELECT *
FROM
(SELECT Table1.Invoice_No, Table1.Product_Name, Table1.Qty*-1 AS Qty
FROM Table1
WHERE Table1.Movement='Out')
UNION
(SELECT Table1.Invoice_No, Table1.Product_Name, Table1.Qty
FROM Table1
WHERE Table1.Movement='In')
September 9, 2005 at 2:03 am
SELECT DT.* FROM
(
Your union query
) AS DT
Giving an alias to the union query will work
September 9, 2005 at 2:11 am
Ha, ha! It works!
Thanks!
September 9, 2005 at 6:47 am
Also I would just try enclosing your statement inside the parens that David provided. I think that is the trick and not the alias...
Good Hunting!
AJ Ahrens
webmaster@kritter.net
September 9, 2005 at 7:28 am
AJ - this works only when used as a derived table - unless I'm missing something very obvious in the syntax (if so, could you pl. be kind enough to post an example ?!?!)
**ASCII stupid question, get a stupid ANSI !!!**
September 9, 2005 at 7:32 am
You're not missing anything... Maybe I'll send some coffee to aj .
September 9, 2005 at 7:48 am
Ok - thx. for confirming remi!
David - You may want to consider changing how your name appears in the posts since we have another (really old time) member of SSC who's also a "David Poole" and funnily enough - stays not too far from where you are - Cheshire, I believe!!!
You may just end up with an identity crisis!!!
**ASCII stupid question, get a stupid ANSI !!!**
September 9, 2005 at 7:52 am
We are one and the same, I've just changed my job.
Really old time member!!!!!!!! OK I have colleagues who are younger than my album collection but I'm not THAT old!
September 9, 2005 at 7:58 am
That's funny!
When I said "old member" I meant member of long standing not chronological years...
can't figure out why you've "reappeared" as yourself instead of just editing your profile ?!?!?!
**ASCII stupid question, get a stupid ANSI !!!**
September 9, 2005 at 8:11 am
Sad though it may be I wanted SSC e-mails to go to my home e-mail address as well as my work address, hence two registrations.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply