有人可以帮我用SQL来检索与JIRA项目相关的用户吗?
答案 0 :(得分:0)
SELECT A.ROLETYPEPARAMETER AS USERNAME, R.NAME AS ROLENAME, P.PKEY || ' - ' || P.PNAME AS PROJECTNAME
FROM PROJECTROLEACTOR A
INNER JOIN PROJECTROLE R ON A.PROJECTROLEID = R.ID
INNER JOIN PROJECT P ON A.PID = P.ID
ORDER BY 3, 1, 2;
或仅汇总每个项目的用户:
SELECT DISTINCT P.PKEY, LISTAGG(A.ROLETYPEPARAMETER, ',') WITHIN GROUP(ORDER BY A.ROLETYPEPARAMETER ASC) OVER(PARTITION BY P.PKEY) AS USERNAMES
FROM PROJECTROLEACTOR A
INNER JOIN PROJECTROLE R ON A.PROJECTROLEID = R.ID
INNER JOIN PROJECT P ON A.PID = P.ID
GROUP BY P.PKEY, A.ROLETYPEPARAMETER;;
答案 1 :(得分:0)
对于Jira 6,正确的MySQL语法是:
SELECT
A.ROLETYPEPARAMETER AS USERNAME,
R.NAME AS ROLENAME, CONCAT(P.pkey, ' - ', P.pname) AS PROJECTNAME
FROM projectroleactor A
INNER JOIN projectrole R ON A.PROJECTROLEID = R.ID
INNER JOIN project P ON A.PID = P.ID
ORDER BY 3, 1, 2
注意:字段名称区分大小写