I have a table like this
Nr | ID | Agent Code |Premium | Plan
-----------------------------------------------------------
345 | 8006194565432 | WW040001 | 60 | Pensioner Plan |
348 | 8006194565432 | WW040001 | 40 | Dependent Adult|
323 | 8006194565432 | WW040001 | 30 | Pensioner Plan |
333 | 1401014565081 | WW040001 | 40 | Pensioner Plan |
-----------------------------------------------------------
I want to sum the premium for the agent WW040001, but it has to count the 3 pensioner plans as 3 plans and the dependent plan as 1 plan.
So the output should be
Agent Code | Count Plans | Total Premium
------------------------
WW040001 | 3 | 170 |
------------------------
How do I do it? It has to count the 345 and 348 as one policy because of the same ID for the different policies.
Nr | ID | Agent Code |Premium | Plan
-----------------------------------------------------------
345 | 8006194565432 | WW040001 | 60 | Pensioner Plan |
348 | 8006194565432 | WW040001 | 40 | Dependent Adult|
323 | 8006194565432 | WW040001 | 30 | Pensioner Plan |
333 | 1401014565081 | WW040001 | 40 | Pensioner Plan |
-----------------------------------------------------------
I want to sum the premium for the agent WW040001, but it has to count the 3 pensioner plans as 3 plans and the dependent plan as 1 plan.
So the output should be
Agent Code | Count Plans | Total Premium
------------------------
WW040001 | 3 | 170 |
------------------------
How do I do it? It has to count the 345 and 348 as one policy because of the same ID for the different policies.