Solved

Union Query - Need another pair of eyes

Posted on 2014-03-12
2
164 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
Comment Utility
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
Comment Utility
thanks that did it.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

762 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

6 Experts available now in Live!

Get 1:1 Help Now