Solved

Multi Table MS Access Query

Posted on 2013-06-04
5
52 Views
Last Modified: 2016-04-01
I have a MS Access database with three (3) tables:

- tbl_Master (primary key on "customer_id).  
1:Many relationship on "account_number" in the "tbl_Relationship table.

- tbl_Accounts (primary key on "account_number")
1:Many relationship on "customer_id" in the "tbl_Relationship table.

- tbl_Relationship (primary key on "customer_id" and "account_number")

I am trying to design a query (or two (2) queries that will show me the following:

QUERY 1
CUSTOMER_ID | TOTAL # of Accounts

I would like this query to show me the total number of accounts associated with each unique customer ID and just show the total.

QUERY 2
CUSTOMER_ID | ACCOUNT_NUMBER | UPDATE_BY | DATE

I would like the query to show me me the account numbers that are associated with each unique customer ID, along with who updated the account and when.

Can anyone help?
0
Comment
Question by:davidkohne
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
MrC63 earned 250 total points
ID: 39220512
For the first query, use:

Select tbl_Master.Customer_ID, Count (tbl_Accounts.Customer_ID) as Total
From tbl_Master
Inner Join tbl_Accounts on tblMaster.Customer_ID=tbl_Accounts.Customer_ID
Group By Customer_ID
0
 
LVL 4

Expert Comment

by:MrC63
ID: 39220517
For query #2, use:

Select Distinct Customer_ID, Account_Number,Update_By,Date
From tbl_Master
Inner Join tbl_Accounts on tblMaster.Customer_ID=tbl_Accounts.Customer_ID
0
 
LVL 40

Assisted Solution

by:Sharath
Sharath earned 250 total points
ID: 39220520
Query 1:

SELECT customer_id,count(*) Total_Accounts
  FROM tbl_Relationship
GROUP BY customer_id

Query 2:

select tbl_Accounts.customer_id,tbl_Relationship.account_number,updated_by,updated_date
  from tbl_Relationship
  inner join tbl_Accounts on tbl_Relationship.customer_id = tbl_Accounts.customer_id
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now