1.
SELECT COUNT(m.id) AS expiringCount FROM meter m
LEFT JOIN meter_certificate mc ON m.id = mc.meter_id AND mc.is_deleted = 0
LEFT JOIN certificate c ON c.id = mc.certificate_id AND c.is_deleted = 0
WHERE m.is_deleted = 0 AND TIMESTAMP(NOW()) > TIMESTAMP(DATE_SUB(c.effective_date,INTERVAL 30 day)) AND TIMESTAMP(NOW()) < TIMESTAMP(c.effective_date);
2.查询时间区间(开始时间:2021-10-10,结束时间2021-1010)
<if test="unitCustSupplierInfoPage.startTime != null and unitCustSupplierInfoPage.endTime != null
and unitCustSupplierInfoPage.startTime != '' and unitCustSupplierInfoPage.endTime != ''">
AND ucs.create_time between #{unitCustSupplierInfoPage.startTime}
and
CONCAT(#{unitCustSupplierInfoPage.endTime}, ' 23:59:59')
</if>