Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to combine 2 Select queries in 1

Status
Not open for further replies.

leifoet

Technical User
Jan 31, 2016
203
BE
After migration (FP=>ASP) I wish to combine 2 UNION-queries in 1 single
but I do not get a query that works.

What is the correct syntax for this ?
Thanks for tips.

sql = "SELECT Date, Description, UAKP, IVKP
FROM ddb18
WHERE memid="&FFFmem&"
UNION ALL
SELECT SELECT Date, Description, UAKP, IVKP
FROM bbk18
WHERE memid="&FFFmem&"
ORDER BY Date ASC"

sql = "SELECT Sum([SumOut]) AS TotOUT, sum([SumIn]) AS TotIN, Sum([SumIN])-sum([SumOUT]) AS Difference
FROM (SELECT Sum(UAKP) AS SumOUT, sum(IVKP) AS SumIN
FROM bbk18
WHERE memid="&FFFmem&"
UNION ALL
SELECT Sum(UAKP) AS SumOUT, sum(IVKP) AS SumIN
FROM ddb18
WHERE memid="&FFFmem&")"


 
Is this actual code?

You have sum([SumOUT[highlight #FCE94F]t[/highlight]]) rather than sum([SumOUT])

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Also each part of the union should have the same number of columns.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top