Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sql 分区统计
SELECT
(
CASE
WHEN minute >= 0
AND minute < 60 THEN
"0~59s"
WHEN minute >= 60
AND minute < 90 THEN
"60~90s"
WHEN minute >= 90
AND minute < 100 THEN
"90~99s"
ELSE
"100+s"
END
) as LEVEL, count(*)
FROM (
SELECT (modtime - addtime) / (1000) AS minute
FROM payinfo_222
) a
GROUP BY
(
CASE
WHEN minute >= 0
AND minute < 60 THEN
"0~59"
WHEN minute >= 60
AND minute < 90 THEN
"60~90"
WHEN minute >= 90
AND minute < 100 THEN
"90~99"
ELSE
"100+"
END
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment