473,320 Members | 1,950 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,320 software developers and data experts.

Does this code provide a unique list of customerIDs

3
Hi All. First post here. I only know enough about Access to get myself in trouble. I have been trying to learn via google search but I think it is easier to ask this question directly.

I have a table of transactions for which I want to query and get a list of unique customer IDs and their names (The ID needs to be unique, not the name). Can you tell me if the code below will do what I want it to (query to find a list of unique customer IDs) or is it really looking for a unique combination of CustomerID and Customer Name?

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCTROW 
  2. tbl_PRODetail.[Customer ID], 
  3. tbl_PRODetail.[Customer Name]
  4. FROM tbl_PRODetail;
I do have concerns that customer names can change and I do not want to duplicate my CustomerID. I will be using this information to append my customer table and since CustomerID is the primary key of my customer table, I do not want any duplicates. Any changes to names are not relevant to my use of this information because even if the name changes, the entity the name represents does not.
Jul 29 '15 #1

✓ answered by jforbes

It will get a unique combination of [Customer ID] AND [Customer Name].

If you need to return a Customer Name and have a Customer Table, I would Join the Customer Table On the Customer ID and Select the Customer Name from the Customer Table instead of the Customer Name from the Detail Table. Doing this would remove the duplicates.

5 1563
jforbes
1,107 Expert 1GB
It will get a unique combination of [Customer ID] AND [Customer Name].

If you need to return a Customer Name and have a Customer Table, I would Join the Customer Table On the Customer ID and Select the Customer Name from the Customer Table instead of the Customer Name from the Detail Table. Doing this would remove the duplicates.
Jul 29 '15 #2
jrg24
3
Would that help me append the customer table with new customer IDs from the detail table? That is my end goal.
Jul 29 '15 #3
Rabbit
12,516 Expert Mod 8TB
That seems a little backwards. You should be adding new customers to the customer table first and then adding order details.
Jul 29 '15 #4
jforbes
1,107 Expert 1GB
Haha, well, looks like you would be getting into a circular reference type of situation. That's no good. I'm guessing you are attempting to Normalize data from an outside source?

If so, then you are attempting to populate a Customer Table from a Detail Table, you will probably need to do something like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT
  2.   tbl_PRODetail.[Customer ID]
  3. , (SELECT TOP 1 d2.[Customer Name] 
  4.    FROM tbl_PRODetail d2 
  5.    WHERE d2.[Customer ID]=tbl_PRODetail.[Customer ID]
  6.   ) AS PossibleCustomerName
  7. FROM tbl_PRODetail
This basically gets a list of all unique Customer ID's, then looks back into the table for the first Customer Name for that Customer ID.

If you are not normalizing data from an outside source, then, as Rabbit states, you might be going about this backwards.
Jul 29 '15 #5
jrg24
3
Yes, it is data from an outside source and I am attempting to normalize it.. This database is just to be used for data analysis. I am keeping the customer list each time I run the data to minimize the number of customer IDs I need to look up from an outside source the next time I update the detail. all detail transactions are deleted and new transactions are added each time I use the DB. Basically my dataset has outgrown excel and I am trying to use Access to summarize the data as much as possible before exporting to excel.
Jul 29 '15 #6

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

Similar topics

2
by: zapazap | last post by:
Dear Snake Charming Gurus, (Was: http://mail.python.org/pipermail/python-list/2004-January/204454.html) First, a thank you to Tim Golden, Thomas Heller, and Mark Hammond for your earlier help...
3
by: Peter Moscatt | last post by:
Does Tkinter provide a combobox or do I have to find some way of making a listbox do the job ? Pete
5
by: Marie | last post by:
Access97 I have a table containing addresses with a separate field for State. Is there a way to create a query that returns an unique list of the states in that table and still be updateable? I...
2
by: cyshao | last post by:
When we copy files in MyComputer, there is a dialog with a ProcessBar and a Cancel button. Does C# provide something like this dialog? Thanks CYShao
1
by: nd02tsk | last post by:
Hello Does PostgreSQL provide anything comparable with the functionality of MySQL Cluster? I appreciate all information. Thank you. Tim
2
by: Someone | last post by:
Hi, What sort of data structures does c# have to create a set. Java allows you to create a set, just wondering what I can use in c#. Will I be forced to implemented custom code?
9
by: active | last post by:
Can you see why this does not sort the list? It displays OK but is not sorted Thanks for any help
16
by: Mark S. | last post by:
I'm a fan of the GUID, but the current project is looking to use a genuinely unique integer. Does the following do that? Math.Abs(System.Guid.NewGuid().GetHashCode()) TIA
1
by: petrofugo | last post by:
what is the purpose of the ArgumentList class i.e what facilities does it provide in Qt programming using c++?
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.