473,666 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1332
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******@btint ernet.com> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.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
12883
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 SURNAME
4
4270
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 to join these tables on the basis of Date. I don't want three rows for each date, i want the values to be added for similar dates. thanx
0
1841
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 and link the 2 tables, so that the first record of A is associated with the fist record of B, the second record of A is associated (I mean,in the same row) with the second record of B and so on...until the last row of A (where x<y). I tried to...
0
1267
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 attendance occurance. I would like to create a report that will total each type of absence in its own column. Can anyone help me with this?
0
1259
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
25537
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 this involve creating virtual tables that link to another database, or am I completely on the wrong track? Any hints as to where I might find more information (buzz-words, etc.) would
12
5551
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
4620
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
1569
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 of many projects. (One statement counts the number of open projects, one counts the number of completed projects, and the third one counts the number of late projects.) The count operations use GROUP BY project to operate. An example of one of...
1
3406
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 Costed and Invoiced data from the same database. I've tried to use a JOIN but it keeps failing. I've got multiple fields that needs to be linked. Any suggestions. I've attached the query to make it easier Declare @IDateFrom DateTime, ...
0
8883
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, 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...
0
8787
jinu1996
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...
1
6203
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 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...
0
5672
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();...
0
4200
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...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
bsmnconsultancy
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...

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.