【发布时间】:2020-06-26 22:50:47
【问题描述】:
我有一个表tab1,在我的数字列c1 中有以下值:
1
2
3
4
5
6
7
8
9
10
13
18
我想回来
1-5
6-10
13
18
下面的查询在 MySQL 而不是 PostgreSQL 中成功执行:
select distinct
case
when c1 between 1 and 5 then '1-5'
when c1 between 6 and 9 then '6-10'
else c1
end as 'c1'
from tab1;
【问题讨论】:
-
我理解了这个问题,冒昧地澄清一下。如果我弄错了,请纠正。
-
为什么要将 1-10 分成两个不同的组
标签: sql postgresql aggregate gaps-and-islands natural-sort