Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Union Query - Need another pair of eyes

Posted on 2014-03-12
2
175 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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

860 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