Hello:
I am trying to create a union query but do not have a lot of experience. Basically I have the below tables:
The Tables: -
Table Name = tblPrior
-
-
CreditRegIDFK; Number; Foreign Key for the Credit Region ID
-
Field Type IndexInfo
-
YearID; Number; Year
-
MonthID; Number; Foreign Key for the Month ID
-
GWP; Number; Gross Premium
-
NWP; Number; Gross Premium
-
ProductIDFK; Number; Foreign Key for the Product ID
-
ProductName; Text; Product Name
-
-
Table Name = tblbudget
-
-
CreditRegIDFK; Number; Foreign Key for the Credit Region ID
-
Field Type IndexInfo
-
YearID; Number; Year
-
MonthID; Number; Foreign Key for the Month ID
-
GWP; Number; Gross Premium
-
NWP; Number; Gross Premium
-
ProductIDFK; Number; Foreign Key for the Product ID
-
ProductName; Text; Product Name
-
-
Table Name = tblCreditRegion
-
-
Field Type IndexInfo
-
CreditRegID; AutoNumber; The Credit ID
-
CreditRegionName; Text; Product Name
-
-
Table Name = tblproduct
-
-
Field Type IndexInfo
-
ProductID; AutoNumber; The Product ID
-
ProductName; Text; Product Name
-
ProductType; Text; Product Type
-
tblbudget has 7,021 records in it and tblPrioir has 3,064. I am trying to create a union query that will give me a total of 10,085. So far I wrote the following union query:
Query Name = UqryProductTypeStatic: - SELECT
-
[DivisionIDFK], [WrkRegIDFK], [CreditRegionName], [ProductType], 0 AS [GWP_PRI], 0 AS [NWP_PRI], [GWP] AS [GWP_BUD], [NWP] AS [NWP_BUD], [MonthID], [YearID], 0 AS [GWP_STAT], 0 AS [NWP_STAT], 0 AS [FWeek]
-
FROM tblProduct
-
INNER JOIN (tblCreditRegion INNER JOIN tblbudget
-
ON tblCreditRegion.CreditRegID = tblbudget.CreditRegIDFK)
-
ON tblProduct.ProductID = tblbudget.ProductIDFK
-
UNION SELECT
-
[DivisionIDFK], [WrkRegIDFK], [CreditRegionName], [ProductType], [GWP] AS [GWP_PRI], [NWP] AS [NWP_PRI], 0 AS [GWP_BUD], 0 AS [NWP_BUD], [MonthID], [YearID], 0 AS [GWP_STAT], 0 AS [NWP_STAT], 0 AS [FWeek]
-
FROM tblProduct
-
INNER JOIN (tblCreditRegion INNER JOIN tblPrior
-
ON tblCreditRegion.CreditRegID = tblPrior.CreditRegIDFK)
-
ON tblProduct.ProductID = tblPrior.ProductIDFK;
-
but my result when I run it is only 7,276. I am not hitting any error when I run it so I am thinking that I must be missing something.
Any ideas or advice would be helpful? P.S. I did run them separately and I get 7,021 and 3,064 so I thought all that would be needed was the UNION SELECT expression....
Thanks,
Keith.
2 4916
Hello:
I am trying to create a union query but do not have a lot of experience. Basically I have the below tables:
The Tables: -
Table Name = tblPrior
-
-
CreditRegIDFK; Number; Foreign Key for the Credit Region ID
-
Field Type IndexInfo
-
YearID; Number; Year
-
MonthID; Number; Foreign Key for the Month ID
-
GWP; Number; Gross Premium
-
NWP; Number; Gross Premium
-
ProductIDFK; Number; Foreign Key for the Product ID
-
ProductName; Text; Product Name
-
-
Table Name = tblbudget
-
-
CreditRegIDFK; Number; Foreign Key for the Credit Region ID
-
Field Type IndexInfo
-
YearID; Number; Year
-
MonthID; Number; Foreign Key for the Month ID
-
GWP; Number; Gross Premium
-
NWP; Number; Gross Premium
-
ProductIDFK; Number; Foreign Key for the Product ID
-
ProductName; Text; Product Name
-
-
Table Name = tblCreditRegion
-
-
Field Type IndexInfo
-
CreditRegID; AutoNumber; The Credit ID
-
CreditRegionName; Text; Product Name
-
-
Table Name = tblproduct
-
-
Field Type IndexInfo
-
ProductID; AutoNumber; The Product ID
-
ProductName; Text; Product Name
-
ProductType; Text; Product Type
-
tblbudget has 7,021 records in it and tblPrioir has 3,064. I am trying to create a union query that will give me a total of 10,085. So far I wrote the following union query:
Query Name = UqryProductTypeStatic: - SELECT
-
[DivisionIDFK], [WrkRegIDFK], [CreditRegionName], [ProductType], 0 AS [GWP_PRI], 0 AS [NWP_PRI], [GWP] AS [GWP_BUD], [NWP] AS [NWP_BUD], [MonthID], [YearID], 0 AS [GWP_STAT], 0 AS [NWP_STAT], 0 AS [FWeek]
-
FROM tblProduct
-
INNER JOIN (tblCreditRegion INNER JOIN tblbudget
-
ON tblCreditRegion.CreditRegID = tblbudget.CreditRegIDFK)
-
ON tblProduct.ProductID = tblbudget.ProductIDFK
-
UNION SELECT
-
[DivisionIDFK], [WrkRegIDFK], [CreditRegionName], [ProductType], [GWP] AS [GWP_PRI], [NWP] AS [NWP_PRI], 0 AS [GWP_BUD], 0 AS [NWP_BUD], [MonthID], [YearID], 0 AS [GWP_STAT], 0 AS [NWP_STAT], 0 AS [FWeek]
-
FROM tblProduct
-
INNER JOIN (tblCreditRegion INNER JOIN tblPrior
-
ON tblCreditRegion.CreditRegID = tblPrior.CreditRegIDFK)
-
ON tblProduct.ProductID = tblPrior.ProductIDFK;
-
but my result when I run it is only 7,276. I am not hitting any error when I run it so I am thinking that I must be missing something.
Any ideas or advice would be helpful? P.S. I did run them separately and I get 7,021 and 3,064 so I thought all that would be needed was the UNION SELECT expression....
Thanks,
Keith.
Keith,
Try changing line 7 To>>>>>> Union ALL Select
Keith,
Try changing line 7 To>>>>>> Union ALL Select
That was it! Thanks a million
Keith.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Paradigm |
last post by:
I am using Access 2K as a front end to a MYSQL database.
I am trying to run a Union query on the MYSQL database. The query is (much
simplified)
SELECT as ID from faxdata UNION
SELECT as ID ...
|
by: Dalan |
last post by:
From reading Access 97 help text, it seems that to do what I need to
do will require a Union Query. As this would be my first, I think I
might require a little guidance.
I have two tables with...
|
by: M Stery |
last post by:
Have two base queries used for mailing labels with
id,name,address,city,state,zip that are combined via a union query.
One base query uses home address; the other base query uses biz
address. I...
|
by: mattytee123 |
last post by:
I have about 20 tables, of which I would like to do a union query and
count of how many of each different code there is?
The simplified verson of the table is structured like this.
Code ...
|
by: BillCo |
last post by:
I'm having a problem with a union query, two simple queries joined with
a union statement. It's created in code based on parameters. Users were
noticing some inconsistant data and when I analysed...
|
by: Thomas |
last post by:
Hi All. I think that if I explain the database layout first it may be
easier to ask my question.
Table Name Field Name
Test TestCode
Description
SpecimenRequirements
FeeSchedule TestCode...
|
by: MLH |
last post by:
How can I turn the following into a make-table query?
SELECT & " " & AS Recipient FROM
tblVehicleJobs INNER JOIN tblAddnlOwnrs ON tblVehicleJobs.VehicleJobID
= tblAddnlOwnrs.VehicleJobID WHERE...
|
by: cashotte |
last post by:
Hi,
Is there a way to have a union query (2 tables) in an other query then
join a third table having the ability to edit records in the third
table?
Thanks,
Stephane
|
by: tasawer |
last post by:
I need some assistance with SQL query. I will be grateful if you can provide help please.
I have a database that records details of a road traffic accident and name of driver.
sub-form records...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |