On Wed, Jul 23, 2008 at 2:32 AM, Sytze de Boer <[EMAIL PROTECTED]> wrote: > Folk, I'm stuck > > I'm trying to extract data from 3 seperate tables as follows > Select date,stockcode,stktype,invnum,SUM(qty) ,sell,desc, "H" as SRCE From > winhst Where stktype=333 UNION ; > Select date,stockcode,stktype,invnum,SUM(qty) ,sell,desc, "J" as SRCE From > wintime Where stktype=333 UNION ; > Select date,stockcode,stktype,invnum,SUM(qty) ,sell,desc, "I" as SRCE From > wininvs Where stktype=333 GROUP BY stockcode ORDER BY stockcode Into Table > &myfile >
What is it you are trying to end up with? Three records of SRCE J, H, and I for each stockcode or only one? Non-aggregating fields have undefined values. Drop them or use something like MAX() to make them aggregating. Finally, try moving the GROUP BY into each statement. The MSDN language reference seems to imply that. -- Ted Roche Ted Roche & Associates, LLC http://www.tedroche.com _______________________________________________ Post Messages to: ProFox@leafe.com Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED] ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.