Link to home
Start Free TrialLog in
Avatar of Dustin Stanley
Dustin Stanley

asked on

MS Access Need Help understanding The Group By Function In a Query

I want to make sure I am understanding the Group By completely in MS Access. Basically I am importing CSV files into Access and I want to Group Customers by several fields. The same customer could have several shipping addresses. Therefore I want to make a record in Access for each shipping address of the customers and if there is several duplicate Shipping Address in the CSV file, I want Access to Group them. The fields I am trying to Group on is:
Company Name
First Name
Last Name
Address Line 1
Address Line 2
City
State
Zip Code
Country
Email address

Basically if any one of these field values is different from the previous record. I want access to show a record in the query results and if it is the EXACT same all the way down the line of fields. I want Access to group all of the similar ones and just show one record.

I have attached a photo of my query grid below and thank you for the help:
User generated image
Avatar of Hamed Nasr
Hamed Nasr
Flag of Oman image

A group makes a unique category from selected properties for a number of things.
For these properties to a customer record.
Company Name
First Name
Last Name
Address Line 1
Address Line 2
City
State
Zip Code
Country
Email address

Open in new window

Choosing Country to uniquely identify customers, then you are looking for one record summarizing all customers of each country.
Select Country FROM tbl Group By Country;

Open in new window

Wait, need the Email address,
Then the unique identifier expanded to Country, [Email address], hence your query will be:
Select Country, [Email address] FROM tbl Group By Country, [Email address];

Open in new window

I want to show customers in country with different [Email address]
Select [First Name], [Last Name], Country, [Email address] From tbl Group By [First Name], [Last Name], Country, [Email address];

Open in new window


Have a go, and comment back if more help is required.
You may upload a few records with required output.
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dustin Stanley
Dustin Stanley

ASKER

Can you use SELECT DISTINCT in the design view or do you have to use SQL only? Thanks for the help.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect and thank you for the help.