How to ??

D

Daniel

Does anyone know to solve the following query .

Select some columns From some tables Where conditions Group By column
Unio
Select some columns From some tables Where conditions Group By Column

After the result being produced, i tried to use the select again towards the result as following .

Select some columns, Sum(column) as TotalIn,Sum(column) as TotalOu
Fro

(Select some columns From some tables Where conditions Group By columns
Unio
(Select some columns From some tables Where conditions Group By Columns

Group by column

the error occurs and this sql is not work.

why ?? Any suggestion to solve it ?

Thax in advance
Daniel.
 
G

GVaught

When you use a Union query the fields used must match in both tables in
datatype as well as size. I don't think you can use a Union query as a
subquery. Try creating the Union query as a separate qry and then use that
query inside your first query linking on a related field.
 
J

JohnFol

Save the union as a query in it's own right (ie MyUnion) and then use it as
the source for the next bit

ie

Select some columns, Sum(column) as TotalIn,Sum(column) as TotalOut
From MyUnion
Group by columns
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top