SELECT
elt(
INTERVAL (
datediff(END_DATE, CURDATE()),
1,
201,
401,
601
),
'0-200',
'200-400',
'400-600',
'>600'
) AS `name`,
COUNT(INDIV_PIN) AS `value`
FROM
t_test
WHERE
`STATUS` = 3
GROUP BY
elt(
INTERVAL (
datediff(END_DATE, CURDATE()),
1,
201,
401,
601
),
'0-200',
'200-400',
'400-600',
'>600'
),INDIV_PIN