预期的结果是字段值按逗号分割,以行的形式展示,然后再group by这些分割出来的字段值,求一个对应的数量,我表达的意思你理解了吗?我把正确的oracle的SQL发给你,你帮我改成pgsql语法的:select t.executor_id, t.EXECUTOR, count(t.executor_id) allcount from( with t as ( select t.executor_id, t.executor from EMP_REPAIR_WORKORDER_BASEINFO t where to_char(t.Create_Date, 'YYYY-MM') = to_char(sysdate, 'YYYY-MM')) select regexp_substr(executor_id, '[^,]+', 1, level) AS executor_id, regexp_substr(executor, '[^,]+', 1, level) executor from t connect by level <= regexp_count(executor_id, '[^,]+') and executor_id = prior executor_id and prior dbms_random.value > 0 ) t group by t.executor_id, t.EXECUTOR
时间: 2023-05-18 18:04:46 浏览: 113
oracle sql 某列的值按照逗号分割显示成多行.sql
以下是转换后的pgsql语法:
SELECT t.executor_id, t.EXECUTOR, COUNT(t.executor_id) allcount
FROM (
WITH t AS (
SELECT t.executor_id, t.executor
FROM EMP_REPAIR_WORKORDER_BASEINFO t
WHERE to_char(t.Create_Date, 'YYYY-MM') = to_char(now(), 'YYYY-MM')
)
SELECT split_part(executor_id, ',', level) AS executor_id, split_part(executor, ',', level) AS executor
FROM t
CONNECT BY level <= regexp_count(executor_id, '[^,] ')
AND executor_id = PRIOR executor_id
AND PRIOR random() > 0
) t
GROUP BY t.executor_id, t.EXECUTOR;
阅读全文