SELECT id, user_name, real_name, email, org_id, last_login_time, created_time, valid_period, always, GROUP_CONCAT(name SEPARATOR ',') AS name, lock_status, latest_failed_time, wrong_pwd_timeFROM tempGROUP BY id, user_name, real_name, email, org_id, last_login_time, created_time, valid_period, always, lock_status, latest_failed_time, wrong_pwd_time;
时间: 2024-03-08 18:48:35 浏览: 199
在Spring中用select last_insert_id()时遇到问题
在 PostgreSQL 中,可以使用 `string_agg()` 函数来实现 `GROUP_CONCAT()` 的功能,其语法为:
```
string_agg(expression, delimiter)
```
其中,`expression` 是要拼接的字段,`delimiter` 是分隔符。
因此,你可以将 `GROUP_CONCAT()` 替换为 `string_agg()`,将查询语句修改为:
```
SELECT
id,
user_name,
real_name,
email,
org_id,
last_login_time,
created_time,
valid_period,
always,
string_agg(name, ',') AS name,
lock_status,
latest_failed_time,
wrong_pwd_time
FROM
temp
GROUP BY
id,
user_name,
real_name,
email,
org_id,
last_login_time,
created_time,
valid_period,
always,
lock_status,
latest_failed_time,
wrong_pwd_time;
```
这样就可以在 PostgreSQL 中执行该 SQL 语句了。
阅读全文