select distinct b.rol_id,(
select stuff(
(select ','+a.ope_id from operator a where a.rol_id=b.rol_id FOR XML PATH(''))
,1,1,'') as ope_ids) as ope_ids
from operator b
结果就出来了。
现有数据如下:用一个SQL查询出每种角色有几个用户,把他们的id用逗号隔开放到一个字段里select distinct b.rol_id,(select stuff((select ','+a.ope_id from operator a where a.rol_id=b.rol_id FOR XML PATH('')),1,1,'') as ope_ids) as ope_idsfrom operator b结果就出来了。...
一、有一张学生表,id为主键不重复,name为学生姓名可以重复。现在想知道重复姓名、重复姓名的人数、以及主键。
二、Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit
SELECT
wm_concat(id),
name,
count(id)
FROM student GROUP BY name
三、mysql 8.0.26
SELECT
group_concat( id ),
`name`,
count( id
项目需要,要在查询中,加上后续处理人查询条件,因为后续处理人字段存的是用户ID串,所以想用函数实现功能:根据用户ID串,返回用户姓名串
根据功能,在数据库查询窗口运行测试,sql如下:没有问题,返回用户姓名串
DECLARE @UserIdStr VARCHAR(1024)
SET @UserIdStr='su20090812001,su20090912002'
select account_id,
substring_index(substring_index(a.related_shop_ids,','
,b.help_topic_id+1),',',-1) shopid
sales_hang_account a
mysql.help_topic b
on b.help_topic_id < (length(a.related_shop_ids) - length(replace(a.related_shop_ids,',',''))+1
select id,
name=stuff((select ','+a.name from TableA a--此处必须定义,用于区分于下方的TableA
where a.id =TableA.id FOR xml PATH('')), 1, 1, '')
from TableA--切记此处不可在定义
group by id
可以使用 SUBSTRING 和 CHARINDEX 函数来截取最后一条数据,具体的 SQL 语句如下:
SELECT SUBSTRING(column_name, CHARINDEX(',', REVERSE(column_name))+1, LEN(column_name)) AS last_data
FROM table_name;
其中,column_name 是包含用逗号隔开的数据的列名,table_name 是包含该列的表名。这条 SQL 语句会返回该列中最后一条数据。
连接redis服务器提示:Redis Client On Error: Error: connect ECONNREFUSED 127.0.0.1:6380 Config right?
32002
eclipse新建项目报错:The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path
17142
Dbeaver连接hive库报错:Required field ‘client_protocol‘ is unset! Struct:TOpenSessionReq(client_protocol:n
JOSON.: