Solved

Multi Table MS Access Query

Posted on 2013-06-04
5
86 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

821 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