473,405 Members | 2,338 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,405 software developers and data experts.

Joining Tables

I am joining these 2 tables together in Access 2003 and can't figure out the exact way of writing this script......Can anyone help?

I have the following SQL:

SELECT PL_Input.Date_ID,Count(PL_Input.[1]+PL_Input.[2]+PL_Input.[3]+PL_Input.[4]+PL_Input.[5]) AS [TO]

FROM Country INNER JOIN PL_Input ON Country.Country_ID = PL_Input.Country_ID

WHERE ((([PL_Input].[1] & "" & [PL_Input].[2] & "" & [PL_Input].[3] & "" & [PL_Input].[4] & "" & [PL_Input].[5]) Like "*2*"))

GROUP BY PL_Input.Date_ID


UNION ALL


SELECT RE_Input.Date_ID, Count(([Six] & "" & [Seven] & "" & [Eight] & "" & [Nine])) AS [TO]

FROM Country INNER JOIN RE_Input ON Country.Country_ID = RE_Input.Country_ID

WHERE ((([Six] & "" & [Seven] & "" & [Eight] & "" & [Nine]) Like "*2*"))

GROUP BY RE_Input.Date_ID;



I am basically trying to count how many TO (total Occurences) where it is equal to 2. I have a form that I built and has check boxes for Pass/Fail that gets inputed into 1,2,3,4,5 and Six,Seven,Eight,Nine for 2 Different Products RE (Real Estate) and PL (Personal Loan). How ever I am having a hard time joining the 2 tables together properly to reflect how many TO happened for the month. The above join was the closest I came to joining them and it does give me the correct results, however, it lists them as such.

Date_ID TO
11/1/2007 1
12/1/2007 4
1/1/2008 1
11/1/2007 1
12/1/2007 3
1/1/2008 1

Is there a way to group by the Date_ID to reflect only one date?

Or is there a better way of joining these tables together?
Feb 8 '08 #1
2 2224
mwasif
802 Expert 512MB
Moved to Access Forum.
Feb 9 '08 #2
MMcCarthy
14,534 Expert Mod 8TB
This should work. However, once you paste it into Access and run it be careful not to edit it or the compiler will probably screw it up trying to impose brackets on it.

Expand|Select|Wrap|Line Numbers
  1. SELECT tmpQry.Date_ID, tmpQry.[TO]
  2. FROM (
  3. SELECT PL_Input.Date_ID,
  4. Count(PL_Input.[1]+PL_Input.[2]+PL_Input.[3]+PL_Input.[4]+PL_Input.[5]) AS [TO]
  5. FROM PL_Input 
  6. WHERE ((([PL_Input].[1] & "" & [PL_Input].[2] & "" & [PL_Input].[3] & "" & [PL_Input].[4] & "" & [PL_Input].[5]) Like "*2*"))
  7. GROUP BY PL_Input.Date_ID
  8. UNION ALL
  9. SELECT RE_Input.Date_ID, 
  10. Count(([Six] & "" & [Seven] & "" & [Eight] & "" & [Nine])) AS [TO]
  11. FROM RE_Input 
  12. WHERE ((([Six] & "" & [Seven] & "" & [Eight] & "" & [Nine]) Like "*2*"))
  13. GROUP BY RE_Input.Date_ID) As tmpQry
  14. GROUP BY tmpQry.Date_ID;
  15.  
Feb 10 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

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...
2
by: James | last post by:
Can anyone please shed some light on the following... I have a framework that uses dynamically created tables, named using an incremental "attribute set ID", as follows: attrdata_1 attrdata_2...
3
by: james | last post by:
Hi, I would like to get all the records from 9 tables that have the same field value in one field (it is a unique field)that is shared by all the tables. Would this method of joining work: ...
1
by: Brian | last post by:
I need help joining info from two tables. Table1 and Table 2 have the same fields(Node,Card,Slot,Facility,Sub-Port,Channel,Group,Cic) Group is text, rest are number. Table 1 contains records for...
2
by: Coquette | last post by:
Hi all. I'm new here. I wanted to ask your opinion about *joining two tables* from *two different database* together. Is *that* possible? My project requires me to join identical tables from...
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...
3
by: Reader | last post by:
Hello all, I am joining two tables in a query and the output should be all those records where two fields in table1 match two corresponding fields in table2. I joined the tables using both...
2
by: nkechifesie | last post by:
I have created 9 tables in access via visdata and need to create another table joining all these tables. I have used the query in visdata to do this but it gives me an outrageous view. I have entered...
4
by: Rnt6872 | last post by:
Table A Table B BOL# B_BOL# Chargeback# Hi All, I have been struggling with this for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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...

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.