Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help with another query
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Help with another query
Divers
Thread ID:
00707822
Message ID:
00707822
Vues:
44
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform