简体   繁体   中英

Rolling up multiple rows into a single row in exasol

I've ran the following query to find out the access rights assigned to each user :

SELECT DISTINCT
       A.GRANTEE AS DB_ACCOUNT,
       B.PRIVILEGE AS ACCESS_RIGHTS
  FROM SYS.EXA_DBA_ROLE_PRIVS A
 INNER JOIN SYS.EXA_DBA_SYS_PRIVS B
    ON A.GRANTED_ROLE = B.GRANTEE;

The output of the query has each user having multiple access rights listed in row by row format, I need all ACCESS_RIGHTS listed into a single row for each user.

For Eg.: The output comes like this for all the users:

EXECUTE
SELECT
CREATE

whereas I need the output as :

EXECUTE, SELECT, CREATE

I NEED A FUNCTION IN EXASOL .

Thanks in advance :)

use group_concat as

group_concat(B.PRIVILEGE) AS ACCESS_RIGHTS

this link might be referenced for the format.

I have got a function in Exasol for rolling up the rows into a single row and the function name is GROUP_CONCAT . Modified query is :

SELECT DISTINCT
A.GRANTEE AS DB_ACCOUNT,
GROUP_CONCAT(B.PRIVILEGE) AS ACCESS_RIGHTS
FROM
SYS.EXA_DBA_ROLE_PRIVS A
INNER JOIN
SYS.EXA_DBA_SYS_PRIVS B
ON
A.GRANTED_ROLE = B.GRANTEE
GROUP BY A.GRANTEE;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM