Hi
There is a table with Car Insurance policies, and I'm trying to find the occupation of the latest policy for the client.
So the table looks like this
- PC_Key= unique key
- Policy_Number
- Rdat= Renewal date
- Client_Ref
- Occup_1 = Occupation
- Bus_Catg = Business Category
A Client could have several policies.
For a client, I'm trying to list the Occup_1 and Bus_Catg of the policy with the most recent Rdat. If the Rdat is the same on twopolicies, use the Occupation of the policy with the highest PC_Key.
I tried doing a view with Max RDat for the client:
SQL
SELECTTOP(100)PERCENTClientRef,MAX(Rdat)ASMax_RdatFROMdbo.Occups_PCGROUPBYClientRefORDERBYMax_RdatDESC
Then linking that
SQL
SELECTdbo.Occups_PC.ClientRef,dbo.Occups_PC.PolicyRef,dbo.Occups_PC.Occup_1,dbo.Occups_PC.Bus_CatgFROMdbo.Occups_PC_Max_RdatINNERJOINdbo.Occups_PCONdbo...