Solved

Union Query - Need another pair of eyes

Posted on 2014-03-12
2
168 Views
Last Modified: 2014-03-12
Getting  error after From?  What am I missing

INSERT INTO tblQuarterly_AchievedPct ( ContractNumber, Quarter, Tier1, Tier2, Tier3, Tier4, Tier5, Tier6 )
SELECT  tblContracts.ContractNumber, 1 AS Qtr, tblContracts.Q1T1, tblContracts.Q1T2, tblContracts.Q1T3, tblContracts.Q1T4, tblContracts.Q1T5, tblContracts.Q1T6
FROM tblContracts
Union All
SELECT  tblContracts.ContractNumber, 2 AS Qtr, tblContracts.Q2T1, tblContracts.Q2T2, tblContracts.Q2T3, tblContracts.Q2T4, tblContracts.Q2T5, tblContracts.Q2T6
FROM tblContracts
Union All
SELECT  tblContracts.ContractNumber, 3 AS Qtr, tblContracts.Q3T1, tblContracts.Q3T2, tblContracts.Q3T3, tblContracts.Q3T4, tblContracts.Q3T5, tblContracts.Q3T6
FROM tblContracts
Union All
SELECT  tblContracts.ContractNumber, 4 AS Qtr, tblContracts.Q4T1, tblContracts.Q4T2, tblContracts.Q4T3, tblContracts.Q4T4, tblContracts.Q4T5, tblContracts.Q4T6
FROM tblContracts

Open in new window

0
Comment
Question by:Karen Schaefer
2 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 39924119
try this

INSERT INTO tblQuarterly_AchievedPct ( ContractNumber, Quarter, Tier1, Tier2, Tier3, Tier4, Tier5, Tier6 )
SELECT A.ContractNumber, A.Qtr, A.Q1T1, A.Q1T2, A.Q1T3, A.Q1T4, A.Q1T5, A.Q1T6
From
(
SELECT  tblContracts.ContractNumber, 1 AS Qtr, tblContracts.Q1T1, tblContracts.Q1T2, tblContracts.Q1T3, tblContracts.Q1T4, tblContracts.Q1T5, tblContracts.Q1T6
FROM tblContracts
Union All
SELECT  tblContracts.ContractNumber, 2 AS Qtr, tblContracts.Q2T1, tblContracts.Q2T2, tblContracts.Q2T3, tblContracts.Q2T4, tblContracts.Q2T5, tblContracts.Q2T6
FROM tblContracts
Union All
SELECT  tblContracts.ContractNumber, 3 AS Qtr, tblContracts.Q3T1, tblContracts.Q3T2, tblContracts.Q3T3, tblContracts.Q3T4, tblContracts.Q3T5, tblContracts.Q3T6
FROM tblContracts
Union All
SELECT  tblContracts.ContractNumber, 4 AS Qtr, tblContracts.Q4T1, tblContracts.Q4T2, tblContracts.Q4T3, tblContracts.Q4T4, tblContracts.Q4T5, tblContracts.Q4T6
FROM tblContracts
) As A
0
 

Author Closing Comment

by:Karen Schaefer
ID: 39924228
thanks that did it.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now