Thanks for the question, Tiku.
Asked: July 27, 2005 - 4:43 pm UTC
Last updated: July 28, 2005 - 9:06 am UTC
Version: 9.2.0
Viewed 1000+ times
You Asked
I have a select statement as follows.
select GRANTEE,table_name,PRIVILEGE
from user_tab_privs
where table_name='TEMP'
and grantee='DEVUSR'
group by GRANTEE,TABLE_NAME,PRIVILEGE;
It returns me data in following format
GRANTEE TABLE_NAME PRIVILEGE
---------------------------- ------------------------------ ---------
DEVUSR TEMP DELETE
DEVUSR TEMP INSERT
DEVUSR TEMP UPDATE
DEVUSR TEMP SELECT
TMPUSR TEMP SELECT
How can I get the output in following format? I'm trying with different approches, inline view, analytic sql but no success so far.
GRANTEE TABLE_NAME DEL_PRIV INS_PRIV SEL_PRIV UPD_PRIV
DEVUSR TEMP Y Y Y Y
TMPUSR TEMP N
Thanks
and Tom said...
call your query "q"
select grantee, table_name,
max(decode(privilege,'DELETE','Y')) del,
......
max(decode(privilege,'UPDATE','Y')) upd
from (Q)
group by grantee, table_name;
very standard "pivot" query.
Rating
(1 rating)
Is this answer out of date? If it is, please let us know via a Comment