SELECT cpr.Id, cpr.CreateTime, cpr.Number FROM CarParkingRegistration cpr
SELECT CONCAT(FORMAT(cpr.CreateTime, 'yyyyMMdd'), FORMAT(ROW_NUMBER() OVER (PARTITION BY CAST(cpr.CreateTime AS DATE) ORDER BY CAST(cpr.CreateTime AS DATE)), '000')) FROM CarParkingRegistration AS cpr WHERE cpr.StartDate IS NOT NULL
重点在于 PARTITION BY 按照时间分组。再定义出ROW_NUMBER。就是我们想要的。