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 = UqryProductType Static: - 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 4948
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 = UqryProductType Static: - 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 from letdata UNION
SELECT as ID FROM MEMODATA;
I get an ODBC error. The same query runs when the backend files are MDB
files and it runs with MYSQL if I only combine 2 tables.
|
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 10 fields that have like data (for instance
both have an item description field, an item price field, a general
notes field, etc.) but with different field names. The tables have
approximately 20/40 other fields that are dissimilar and not needed...
|
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 only want one label per person. In a few cases, I have a
record with both a home address and a biz address, which I don't want
in the labels. How or can I make the union query omit an id in the biz
address base query IF that same id has a record in...
|
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 Count
1234 1
2468 1
1234 1
2468 1
|
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 the query produced
and opened it from a MS Query it started giving strange results.
The first query when run alone returns 22 records, some of which have
identical values in all fields. This is 100% correct.
The second query returns nothing....
| |
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
CPTCode
|
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
tblVehicleJobs.VehicleJobID=GetCurrentVehicleJobID();
UNION SELECT AS Recipient FROM tblVehicleJobs INNER
JOIN tblLienHolders ON tblVehicleJobs.VehicleJobID =
tblLienHolders.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 names of passengers.
The two tables are related with a one-to-many relationship.
I need to view all the names (Drivers and Passengers) as datasheet view and be able to tick a box to show investigation for this particular person is complete.
I...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |