473,408 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

joining queries

Hi
i have a table which records the number of cards issued to a team
fields are

Team text
Numof yellow integer
numor Red integer
date yellow short date
date red short date

query1
assigns years months and weeknumber to both date yellow and date red

query 2
returns team numof yellow total of cards based on a year ie 2005

query 3
returns team numof red total of cards based on a year ie 2005

what i want to do now is put join query2 and query3 to get a combine
result

ie Team numof yellow numof red Total
team 1 4 2 6
team 2 2 3 5
team 3 6 4 10

what i am getting is duplicate record
ie

Team numof yellow numof red Total
team 1 2 2
team 1 4 4
team 2 3 3
team 2 2 2
team 3 6 6
team 3 4 4

Can anyone please tell me how to resolve this

thanks

kevin

Nov 13 '05 #1
4 1323
Assuming that your table is fully populated, you should be able to do it in
a single query:

SELECT Team, Sum(NumOfYellow) AS TotalYellow,
Sum(NumOfRed) AS TotalRed,
Sum(NumOfYellow) + Sum(NumOfRed) AS Total
FROM MyTable
WHERE Year([DateYellow]) = 2005
OR Year([DateRed]) = 2005
GROUP BY Team

(Warning: the above is untested air code. You may have to futz around with
it a little bit...)

The easiest way is to type the SQL in directly, rather than trying to do
this through the graphical query designer. When the query's in Design mode,
choose SQL view on the View menu.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"kevcar40" <ke******@btinternet.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi
i have a table which records the number of cards issued to a team
fields are

Team text
Numof yellow integer
numor Red integer
date yellow short date
date red short date

query1
assigns years months and weeknumber to both date yellow and date red

query 2
returns team numof yellow total of cards based on a year ie 2005

query 3
returns team numof red total of cards based on a year ie 2005

what i want to do now is put join query2 and query3 to get a combine
result

ie Team numof yellow numof red Total
team 1 4 2 6
team 2 2 3 5
team 3 6 4 10

what i am getting is duplicate record
ie

Team numof yellow numof red Total
team 1 2 2
team 1 4 4
team 2 3 3
team 2 2 2
team 3 6 6
team 3 4 4

Can anyone please tell me how to resolve this

thanks

kevin

Nov 13 '05 #2
THanks

Nov 13 '05 #3
hi again
if i include red_month and yellow_month can i still use the same
process
ie year 2005 and month june
i have tried altering the query but it is returning everything

thanks again

kevin

Nov 13 '05 #4
hi again
if i include red_month and yellow_month can i still use the same
process
ie year 2005 and month june
i have tried altering the query but it is returning everything

thanks again

kevin

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Matt O'Donnell | last post by:
Does anyone know how I can 'join' the results of one SQL query to the bottom of another? Eg. I have two queries: 1. SELECT Name, Surname FROM People WHERE Surname = Smith NAME ...
4
by: Job Lot | last post by:
Is there anyway of Joining two or more DataTable with similar structure? I have three DataTables with following structures Data, AmountB/F, Repayments, InterestCharged and AmountC/F i want...
0
by: Gianfranco | last post by:
Hi I got a problem with 2 tables. I have a table, say A, with x records, coming from a make table query and a table, say B, with y records, coming from another make table query. I need to join...
0
by: Norma | last post by:
I have 2 queries that pull attendance records depending on the type of attendance occurance, or Both queries are drawn off 1 table where the field will depict whether it is a punctuality or...
0
by: dkintheuk | last post by:
Hi all, I'm trying to output a result set from some data as follows: I have raw data with the following columns Date, Country, System, ID,
10
by: Captain Nemo | last post by:
Hi I'm working on an ASP project where the clients want to be able to effectively perform SELECT queries joining tables from two different databases (located on the same SQL-Server). Does...
12
by: veaux | last post by:
Question about joins in queries. I have 2 tables with a field called "ID". Table 1 Rec1 = Jan12FredFlintstone Rec2 = Feb01WilmaRubble Table 2 Rec1 = Jan12BarneyRubble Rec2 = Mar03SamSlate
4
by: jason.teen | last post by:
Hi, when i am joining on a Column of Text Type with one of Memo type the resulting entry has funny chinese characters! Has anyone else encountered this before? Is there a cure?? Cheers.
3
by: nickvans | last post by:
Hello everyone, I am new to SQL Server, and am having trouble joining several SELECT statements together. I have three SQL Select statements that do separate count operations to get the status...
1
by: bhavinnaik | last post by:
Hi I am new to the IT enviro...although i've used QSL query for a while now but on simple or single queries. Here is the problem... I've got two queries looking at a set of tables to extract the...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
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...
0
isladogs
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...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.