Hello DBA's. I have a query that selects all the insured policies from the previous year, as shown below:
select MotorCINo,
IssuanceType,
VehicleType,
VehiclePower,
VehicleChasisNo,
InsuranceType,
InsuranceOption,
PeriodFrom,
PeriodTo
from tblMotorInsurance_eCI
where YEAR(PeriodFrom) = YEAR(DATEADD(year,-1,GETDATE())) and PeriodTo < CAST(getdate() as date) and IssuanceType <> 'Short Term'
order by PeriodFrom desc
The output is also shown below:

How do I get the list of motor vehicles that did not renew the policy this year? Thank you in advance.

Jes SiePosted Nov 3, 2023, 4:49 AM
If querying the whole year, it takes so long for the data to display. So, I made a between-period. Below is my query and so far it serves the purpose:
Jes SiePosted Nov 3, 2023, 4:06 AM
Thank you so much, Jignesh. I tested your recommended query; however, I found that the motor vehicle that was renewed this year exists in the result set.
Jignesh KumarPosted Nov 3, 2023, 4:00 AM
Hello Hold,
Please check for PeriodFrom, it should be in current year and not null.