SELECT
case
when DURATION_IN_MS BETWEEN 115000 AND 120000 THEN '115000-120000'
when DURATION_IN_MS BETWEEN 120001 AND 125000 THEN '120001-125000'
else 'OTHERS'
END AS grp,
COUNT(*) AS cnt
from tab1
GROUP BY grp
就像ysth在评论中说的,把范围分开。 case语句将类别定义为grp,我们将GROUP BY this和count(*)的数量定义为每组。
1条答案
按热度按时间3htmauhk1#
参考:fiddle
就像ysth在评论中说的,把范围分开。
case语句将类别定义为
grp
,我们将GROUP BY
this和count(*)
的数量定义为每组。