ORACLE数据库:表A 部门表 :字段:dept_id(部门ID) pid(上级单位ID) dept_name(部门名
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/28 07:48:12
ORACLE数据库:表A 部门表 :字段:dept_id(部门ID) pid(上级单位ID) dept_name(部门名称) dept_type
ORACLE数据库:
表A 部门表 :字段:dept_id(部门ID) pid(上级单位ID) dept_name(部门名称) dept_type(部门类型 0:部门,1:单位,就是上级单位)
表B 人员表:字段:user_id dept_id(所属部门ID)
表C 住房表:字段:building_id user_id lh_id(楼号ID)
表D 楼号表:字段:lh_id lh_type(楼的类型a 0:老城,1:新城) lh_kind(楼的类型B 0:多层,1:高层)
需要的结果:
单位 部门 新城多层 新城高层 老城多层 老城高层 小计
单位A 部门A 5 10 40 20 75
单位B.
ORACLE数据库:
表A 部门表 :字段:dept_id(部门ID) pid(上级单位ID) dept_name(部门名称) dept_type(部门类型 0:部门,1:单位,就是上级单位)
表B 人员表:字段:user_id dept_id(所属部门ID)
表C 住房表:字段:building_id user_id lh_id(楼号ID)
表D 楼号表:字段:lh_id lh_type(楼的类型a 0:老城,1:新城) lh_kind(楼的类型B 0:多层,1:高层)
需要的结果:
单位 部门 新城多层 新城高层 老城多层 老城高层 小计
单位A 部门A 5 10 40 20 75
单位B.
select t11.organ_name "单位",
t11.dept_name "部门",
count(case when t14.lh_type=1 and t14.lh_kind=0 then 1 else null end) "新城多层",
count(case when t14.lh_type=1 and t14.lh_kind=1 then 1 else null end) "新城高层",
count(case when t14.lh_type=0 and t14.lh_kind=0 then 1 else null end) "老城多层",
count(case when t14.lh_type=0 and t14.lh_kind=1 then 1 else null end) "老城高层",
count(1) "小计"
from (select t1.dept_name organ_name,t2.dept_name,t2.dept_id
from (select dept_id,dept_name from a where dept_type = 1) t1,
(select pid,dept_id,dept_name
from A
where dept_type = 0) t2
where t1.dept_id = t2.pid) t11,
B t12,
C t13,
D t14
where t11.dept_id = t12.dept_id
and t12.user_id=t13.user_id
and t13.lh_id=t14.lh_id
group by t11.organ_name,
t11.dept_name
t11.dept_name "部门",
count(case when t14.lh_type=1 and t14.lh_kind=0 then 1 else null end) "新城多层",
count(case when t14.lh_type=1 and t14.lh_kind=1 then 1 else null end) "新城高层",
count(case when t14.lh_type=0 and t14.lh_kind=0 then 1 else null end) "老城多层",
count(case when t14.lh_type=0 and t14.lh_kind=1 then 1 else null end) "老城高层",
count(1) "小计"
from (select t1.dept_name organ_name,t2.dept_name,t2.dept_id
from (select dept_id,dept_name from a where dept_type = 1) t1,
(select pid,dept_id,dept_name
from A
where dept_type = 0) t2
where t1.dept_id = t2.pid) t11,
B t12,
C t13,
D t14
where t11.dept_id = t12.dept_id
and t12.user_id=t13.user_id
and t13.lh_id=t14.lh_id
group by t11.organ_name,
t11.dept_name
ORACLE数据库:表A 部门表 :字段:dept_id(部门ID) pid(上级单位ID) dept_name(部门名
一道sql 题目某公司数据库的两个关系:部门(部门号,部门名,负责人,电话)和员工(员工号,姓名,住址)。假设每个部门有
oracle 有哪些部门
部门 人数 部门利润 (万元)
oracle 表a,有3列,id,start(date),end(date)
一张表table,树形结构,id唯一标识,name姓名,pid上级id, 求一条sql语句查询出某人所有下属员工
总部,上级部门用英语怎么说?
上级主管、部门主任用英语怎么说
英语翻译日韩女歌手部门第1名,全球歌手部门第24名(包括男歌手),而排在日韩女歌手部门第2位的ayu,在全球歌手部门仅仅
某地机关有三个部门,A部门有公务员40名,B部门有公务员28名,C部门有公务员32名,如果每个部门按相同比例裁减人员,使
decode函数用法在emp表中,为所有人长工资,标准是:10部门长10%;20部门长15%;30部门长20%其他部门长
关于行政系统内部监督问题.行政系统内部监督包括上级政府、审计部门、监察部门、法制部门.其中,后三项都包括哪些部门?