Skip to content
Advertisement

How to get unique customer names those have different IDS

I am working with a table that contains Account_No as unique ID, Customer_Name, Building_Name. The table below is an example:

Customer table

It can be seen for few cases there are same customer name and same building however different Account_No. I need to remove duplicate names even though they have unique Account_No. Building_Name and Customer_Name are ties together. For example “William—-Science City” and “William—–River Club” should be count as two customers since they are residing in different buildings. The result table should look as below;

Result Customer Table

I need to use SQL for creating the resulting table. Kindly use Customer Table as the reference for SQL query. Thanks

Advertisement

Answer

Select Min(Account_No) As Account_No
       ,Customer_Name,Building_Name
From Customer_Table
Group By Customer_Name, Building_Name
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement