Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Select customers with multiple addresses

enter image description here

I have a customer table and want to select customers with multiple addresses.

I create the following query, but the customer(105) with the same address and different account is coming to my result

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

select *
from [Cutomer]    
where Customer_ID in (
   select [Customer_ID]       
   from [CuatomerA]
   group by [Customer_ID]
   having count(*) > 1
)

>Solution :

select *
from [Cutomer]    
where Customer_ID in (
   select [Customer_ID]       
   from [CuatomerA]
   group by [Customer_ID]
   having count(distinct [Address]) > 1
)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading