I have 2-3 multiple policies with same policy no like if i have policy 00/34 then there is 2-3 multiple records of this policies but other columns of this policy is different only policy_no is same .. i want to get minium date against policy like if have this kind of data
policy no fromdate todate sa_year status month_diff status(what i want)
123 23-05-2019 22-06-2020 2019 LOST 13 new
123 28-07-2019 22-06-2020 2019 NEW 11 renew
123 28-07-2019 27-12-2020 2019 LOST 13 renew
i want to do if last record of each policy todate is less than current date against each same policy then last record should be lost otherwise when todate is greater than current date then record should be renew .. and first record of each same policy which has min date should be new .. because this policy came first time .. and point is if policy not complete 1 year then should be new .. if policy complete 1 year then status should be "renew"
i tried this script
Load Distinct
POLICY_NO as [Child Policy],
OLD_POLICY_NUMBER as [Parent Policy],
sa_YEAR,
[From Date],
[To Date],
Policy_Effective_Year,
month_diff ,
if((Policy_Effective_Year=Year(Today()) and
sa_YEAR=Year(Today()) AND month_diff < 12),'NEW',
if(Min(todate),POLICY_NO < date(today()),'LOST','RENEW')) AS
STATUS,
FROM
table_1.qvd
(qvd);