How to achieve the below goal in obiee dashboard

拟墨画扇 提交于 2019-12-24 15:46:12

问题


I have a table like below:

id name role1 role2 role3
-------------------------
1  John   y    n      y
2  Pete   n    y      y
3  Den    n    y      y
4  Mat    y    n      n

After I filter the table by using role1='Y', I lost Pete and Den.

How can I use the analysis to build a table like below:

       Count (Y)
Role1    3
Role2    2
Role3    3

I tried everything. Please help

Thanks


回答1:


If your database is Oracle 11g or later you can use the unpivot clause

SELECT usr_role,
  COUNT(*) role_count
FROM
  (SELECT  * 
     FROM table_name 
     UNPIVOT (hasRole FOR usr_role IN (role1,role2,role3))
  WHERE hasRole = 'y'
  )
GROUP BY usr_role ;

This returns:

USR_ROLE  ROLE_COUNT
ROLE3      3
ROLE1      2
ROLE2      2

You could use this query as an opaque view in the RPD



来源:https://stackoverflow.com/questions/19036958/how-to-achieve-the-below-goal-in-obiee-dashboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!