By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,663 Members | 1,827 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,663 IT Pros & Developers. It's quick & easy.

How do I add to Union Query

P: 418
A union query named qryUnionGrant has this in the SQL

Expand|Select|Wrap|Line Numbers
  1. SELECT ECHOID, GrantNo, FundNo, AcctNo,SubClassNo, ProjectNo, Amount,"Allocation" as Category
  2. FROM qryAllocDetail
  4. UNION SELECT ECHOID, GrantNo, FundNo, AcctNo,SubClassNo, ProjectNo, PayAmount, "Payroll" as Category
  5. FROM qryPayDetail;
  8. UNION SELECT ECHOID,GrantNo, FundNo, AcctNo,SubClassNo, ProjectNo, NetAmount, "AP" as Category
  9. FROM qryApDetail;
I need to add qryEcho to this. But qryEcho does not have similar fields. All I am trying to do is to pull the EchoNo and NOT ECHOID from qryEcho. My goal is list each grant total amount by fund, Sub class, Project and Echo Number.

Any guidance from anyone?
Jun 24 '09 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 2.5K+
P: 2,545
Hi. The field names in the union query do not have to be the same, so there is no reason why you cannot union what you have got with a

SELECT EchoNo, ...., FROM qryEcho;

You must, however, union the same number of fields - and they should be of the same type or one which is compatible with the final type (e.g. if the third field is a date type in one SELECT statement it should be a Date type in them all).

I suspect that you do not need to use a Union query at all, and that what you really need is a join of some kind in a standard query. I can't comment further on this as you have not told us what the additional query does or how it relates to the unioned ones you list.

Jun 24 '09 #2

P: 418

I solved it. I simply replaced Select ECHOID with Select EchoNo in the Union Query - and it worked. Now onto my report. Thanks.
Jun 24 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.