我的查询为用户分配到的每个组返回多行,示例如下:
我需要将每个用户的每个组连接到一行,如下所示:A组、B组、C组
我试过使用SUBSTRING、SUB SELECT、GROUP_CONCAT..到目前为止没有任何效果。
下面是返回示例图像的查询
SELECT DISTINCT { customer.uid } AS email,
{ customer.lastLogin } AS lastLogin,
{ customer.company } AS company,
{ unit.topLevel } AS site,
{group.uid} AS groups
FROM { B2BCustomer AS customer
JOIN CustomerCMSSiteRelation AS site
ON { site.source } = { customer.PK }
JOIN B2BUnit AS unit
ON {customer.defaultB2BUnit} = {unit.pk}
JOIN PrincipalGroupRelation AS rel ON {customer:PK} = {rel:source}
JOIN UserGroup AS group ON {rel:target} = {group:PK} }
WHERE {unit.topLevel} = 'AR'
1条答案
按热度按时间yduiuuwa1#
string_agg()
不起作用,请将其替换为group_concat