I have following query. I need MODEL_YEAR_FW 2003 to 2022 to be grouped 3 years each
SELECT
COUNT(VEHICLE_FW.MODEL_YEAR_FW) AS COUNT_VEHICLES,
VEHICLES_FW.MODEL_YEAR_FW AS MODEL_YR
FROM
FWUSER.VEHICLES_FW
WHERE
VEHICLES_FW.ARCHIVE_STATUS_FW - 'N'
AND ( (MODEL_YEAR_FW) >2003)
GROUP BY
VEHICLE_FW.MODEL_YEAR_FW
ORDER BY
VEHICLES_FW.MODEL_YEAR_FW
Someone please help me
2
Answers
You could use the modulo operator
%
You may use
DENSE_RANK()
analytic function as the following:See a demo.