【发布时间】:2018-10-03 20:07:17
【问题描述】:
我有一张桌子:
我的选择:
select regexp_split_to_table(t3."Id"::character varying,'') as s
from (select t1."Id" from table1 t1
union all
select t2."Id"from table2 t2) t3
order by s
或者我也可以用这个得到一个字符串'22173345566179111134546175622323811':
select string_agg(t3."Id"::character varying,'') as s
from (select t1."Id" from table1 t1
union all
select t2."Id"from table2 t2) t3
我需要得到一个包含 number|count 数据的表格,我的意思是任何数字都可以在选择中获取重复次数,例如:
1 | 9
2 | 5
3 | 5
等等..
PostgreSQL 数据库管理系统
【问题讨论】:
标签: sql postgresql select count