查询人员所属组,以及查询组对应的上一级组
2012-06-21 15:10
585 查看
select rgv.GROUP_ID ,rgv.GROUP_NAME ,rgv.RELATED_GROUP_ID,rgv.RELATED_GROUP_NAME
from(
select row_number() over(PARTITION BY GROUP_ID ORDER BY fSign desc ) rn ,rg.*
from(
SELECT B.GROUP_RELATE_ID,
B.GROUP_ID,
A.GROUP_NAME,
B.RELATED_GROUP_ID,
C.GROUP_NUMBER RELATED_GROUP_NUMBER,
C.GROUP_NAME RELATED_GROUP_NAME,
B.RELATION_TYPE,
D.MEANING RELATION_TYPE_NAME,
B.START_DATE_ACTIVE,
B.END_DATE_ACTIVE,
B.DELETE_FLAG,
B.OBJECT_VERSION_NUMBER,
B.CREATED_BY,
B.CREATION_DATE,
B.LAST_UPDATED_BY,
B.LAST_UPDATE_DATE,
B.LAST_UPDATE_LOGIN
,case when sysdate between b.start_date_active and nvl(b.end_date_active,sysdate) then 1 else 0 end fb
,case when sysdate between a.START_DATE_ACTIVE and nvl(a.end_date_active,sysdate) then 1 else 0 end fa
,case when sysdate between c.START_DATE_ACTIVE and nvl(c.end_date_active,sysdate) then 1 else 0 end fc
,nvl((case when nvl(b.delete_flag,'N')='N' then 1 else 0 end ),0) fbd
,case when sysdate between b.start_date_active and nvl(b.end_date_active,sysdate) then 1 else 0 end
+case when sysdate between a.START_DATE_ACTIVE and nvl(a.end_date_active,sysdate) then 1 else 0 end
+case when sysdate between c.START_DATE_ACTIVE and nvl(c.end_date_active,sysdate) then 1 else 0 end
+nvl((case when nvl(b.delete_flag,'N')='N' then 1 else 0 end ),0) fsign
from JTF_RS_GRP_RELATIONS B,
JTF_RS_GROUPS_VL A,
JTF_RS_GROUPS_VL C,
fnd_lookups d
WHERE a.group_id = b.group_id
and c.group_id = b.related_group_id
and b.relation_type = d.lookup_code
and d.lookup_type = 'JTF_RS_RELATION_TYPE'
) rg
) rgv where rn=1
select SOURCE_LAST_NAME,group_name
from(
select SOURCE_LAST_NAME,group_name
,row_number() over(PARTITION BY SOURCE_LAST_NAME ORDER BY fSign desc ) rn
from(
select distinct rds.RESOURCE_NAME , rds.SOURCE_LAST_NAME, rdg.group_name --,rdr.role_name(角色会重复)
,case when sysdate between rds.START_DATE_ACTIVE and nvl(rds.END_DATE_ACTIVE,sysdate) then 1 else 0 end fRDS
,case when sysdate between rdg.group_start_date and nvl(rdg.group_end_date,sysdate) then 1 else 0 end fRDG
,case when sysdate between rdr.RES_RL_START_DATE and nvl(rdr.RES_RL_END_DATE,sysdate) then 1 else 0 end fRDR
,rdg.delete_flag fRDG_del
,rdr.delete_flag fRDR_del
,nvl((case when sysdate between rds.START_DATE_ACTIVE and nvl(rds.END_DATE_ACTIVE,sysdate) then 1 else 0 end),0)
+nvl((case when sysdate between rdg.group_start_date and nvl(rdg.group_end_date,sysdate) then 1 else 0 end),0)
+nvl((case when sysdate between rdr.RES_RL_START_DATE and nvl(rdr.RES_RL_END_DATE,sysdate) then 1 else 0 end),0)
+nvl((case when nvl(rdg.delete_flag,'N')='N' then 1 else 0 end ),0)
+nvl((case when nvl(rdr.delete_flag,'N')='N' then 1 else 0 end ),0) fSign
from JTF_RS_DEFRESOURCES_VL rds
,jtf_rs_defresgroups_vl rdg
,jtf_rs_defresroles_vl rdr
where rds.RESOURCE_ID=rdg.RESOURCE_ID
and rdg.GROUP_MEMBER_ID=rdr.role_resource_id
) pg
)pgv
where pgv.rn=1
from(
select row_number() over(PARTITION BY GROUP_ID ORDER BY fSign desc ) rn ,rg.*
from(
SELECT B.GROUP_RELATE_ID,
B.GROUP_ID,
A.GROUP_NAME,
B.RELATED_GROUP_ID,
C.GROUP_NUMBER RELATED_GROUP_NUMBER,
C.GROUP_NAME RELATED_GROUP_NAME,
B.RELATION_TYPE,
D.MEANING RELATION_TYPE_NAME,
B.START_DATE_ACTIVE,
B.END_DATE_ACTIVE,
B.DELETE_FLAG,
B.OBJECT_VERSION_NUMBER,
B.CREATED_BY,
B.CREATION_DATE,
B.LAST_UPDATED_BY,
B.LAST_UPDATE_DATE,
B.LAST_UPDATE_LOGIN
,case when sysdate between b.start_date_active and nvl(b.end_date_active,sysdate) then 1 else 0 end fb
,case when sysdate between a.START_DATE_ACTIVE and nvl(a.end_date_active,sysdate) then 1 else 0 end fa
,case when sysdate between c.START_DATE_ACTIVE and nvl(c.end_date_active,sysdate) then 1 else 0 end fc
,nvl((case when nvl(b.delete_flag,'N')='N' then 1 else 0 end ),0) fbd
,case when sysdate between b.start_date_active and nvl(b.end_date_active,sysdate) then 1 else 0 end
+case when sysdate between a.START_DATE_ACTIVE and nvl(a.end_date_active,sysdate) then 1 else 0 end
+case when sysdate between c.START_DATE_ACTIVE and nvl(c.end_date_active,sysdate) then 1 else 0 end
+nvl((case when nvl(b.delete_flag,'N')='N' then 1 else 0 end ),0) fsign
from JTF_RS_GRP_RELATIONS B,
JTF_RS_GROUPS_VL A,
JTF_RS_GROUPS_VL C,
fnd_lookups d
WHERE a.group_id = b.group_id
and c.group_id = b.related_group_id
and b.relation_type = d.lookup_code
and d.lookup_type = 'JTF_RS_RELATION_TYPE'
) rg
) rgv where rn=1
select SOURCE_LAST_NAME,group_name
from(
select SOURCE_LAST_NAME,group_name
,row_number() over(PARTITION BY SOURCE_LAST_NAME ORDER BY fSign desc ) rn
from(
select distinct rds.RESOURCE_NAME , rds.SOURCE_LAST_NAME, rdg.group_name --,rdr.role_name(角色会重复)
,case when sysdate between rds.START_DATE_ACTIVE and nvl(rds.END_DATE_ACTIVE,sysdate) then 1 else 0 end fRDS
,case when sysdate between rdg.group_start_date and nvl(rdg.group_end_date,sysdate) then 1 else 0 end fRDG
,case when sysdate between rdr.RES_RL_START_DATE and nvl(rdr.RES_RL_END_DATE,sysdate) then 1 else 0 end fRDR
,rdg.delete_flag fRDG_del
,rdr.delete_flag fRDR_del
,nvl((case when sysdate between rds.START_DATE_ACTIVE and nvl(rds.END_DATE_ACTIVE,sysdate) then 1 else 0 end),0)
+nvl((case when sysdate between rdg.group_start_date and nvl(rdg.group_end_date,sysdate) then 1 else 0 end),0)
+nvl((case when sysdate between rdr.RES_RL_START_DATE and nvl(rdr.RES_RL_END_DATE,sysdate) then 1 else 0 end),0)
+nvl((case when nvl(rdg.delete_flag,'N')='N' then 1 else 0 end ),0)
+nvl((case when nvl(rdr.delete_flag,'N')='N' then 1 else 0 end ),0) fSign
from JTF_RS_DEFRESOURCES_VL rds
,jtf_rs_defresgroups_vl rdg
,jtf_rs_defresroles_vl rdr
where rds.RESOURCE_ID=rdg.RESOURCE_ID
and rdg.GROUP_MEMBER_ID=rdr.role_resource_id
) pg
)pgv
where pgv.rn=1
相关文章推荐
- Hibernate一级、二级缓存以及查询缓存的理解
- 查询本网段中的IP地址以及对应的电脑的信息
- java之nslookup小程序--查询IP地址以及对应域名
- MS SQL 查询数据库中所有索引以及对应的表字段 SQL Server Profiler性能跟踪
- Oracle EBS-SQL (SYS-3):sys_人员用户名对应关系查询.sql
- oracle 查询对应表空间里面存储的表,以及更换表的表空间
- ObjectContext 是开发人员在查询、添加和删除其实体实例以及将新状态保存回数据库时用到的主要构造
- 查询当前数据库中所有表名 以及表对应的行数
- 百度地图API根据某个经纬度值(地理坐标)查询对应的地址信息以及该地址周边的POI(Point of Interest,兴趣点)信息
- Oracle EBS-SQL (SYS-21):sys_用户名与人员对应关系查询.sql
- windows查询占用端口的pid以及查询对应的进程名称
- 加州大学以及全美公立大学工作人员工资查询
- windows查询占用端口的pid以及查询对应的过程名称
- hibernate--一级和二级缓存(使用Ehcache)以及查询缓存
- oracle 查询对应表空间里面存储的表,以及更换表的表空间
- 查询出每个雇员的姓名,工资,部门名称,工资在公司的等级及其领导的姓名,领导的工资,以及领导所对应的等级
- 使用子查询的方式找出属于Action分类的所有电影对应的title以及description
- php mysql查询3级分类下对应的一级和二级分类
- 查询数据库锁以及锁对应SQL语句的若干查询SQL
- oracle 查询对应表空间里面存储的表,以及更换表的表空间