Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with another query
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Help with another query
Miscellaneous
Thread ID:
00707822
Message ID:
00707822
Views:
43
I have a query that finds duplicate customers using the same credit card:
select iproductid,caccount,count(caccount) as cnt  
from customer c
group by iproductid,caccount
having count(caccount)>2
order by iproductid,cnt
This gives me results like
iproductid  caccount                       cnt         
----------- ------------------------------ ----------- 
1           xxx                            3
1           yyy                            3
Now I want another column that tells me "of those customers using the same credit card, how many have the same last name?"

I probably could do it with cursors and maybe a UDF, but is there another way using the select? When I try I correlated subquery, I can't get the number of records to be returned to me.
TIA
Next
Reply
Map
View

Click here to load this message in the networking platform