I have a table in which I am saving the policy ids and have another table in which i am saving all the customers mapped to that policy
When I have performed inner join between two tables I am getting the data in the below format
Policy Id | Customer |
---|---|
1 | A |
1 | B |
1 | C |
2 | A |
2 | B |
I can see in above data that Customer A has 2 policies, Customer B has 2 policies and Customer C has 1 policy
I have tried to write the query
select CustomerName,COUNT(policyid) as PolicyCount from Dummy
group by clientId,policyid
Please see the output here
I have mentioned Customer A, B and C instead of 1 ,2 and 3
Output should be like
Customer | Policy Count |
---|---|
A | 2 |
B | 2 |
C | 1 |
Please help me here how we can achieve it via query
Chirag Gupta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.