查出所有员工所在的分公司sql语句。
来源:互联网 发布:微信小程序上传数据 编辑:程序博客网 时间:2024/05/16 17:55
select nvl((nvl((select b.name from depart_name_view b where dorder>1 and instr((select a.plist from oa_depart a where a.id = t.fid),b.id||',') <> 0),(select b.name from depart_name_view b where dorder=1 and instr((select a.plist from oa_depart a where a.id = t.fid), ','||b.id||',') <> 0))),(select b.name from depart_name_view b where dorder=1 and b.id=t.fid)) as fgs_name,
t.id,
t.fid,
t.username,
t.password,
t.partlist,
t.realname,
t.sex,
t.birth,
t.idcard,
t.native,
t.nation,
t.culture,
t.polity,
t.address,
t.zip,
t.homephone,
t.telphone,
t.mobile,
t.email,
t.depart,
t.duty,
t.employtype,
t.postdate,
t.leftdate,
t.memo,
t.fig,
t.bossgh,
t.salemember,
t.disabled,
t.updateuser,
t.updatetime,
t.createuser,
t.createtime
from oa_employees t;
同事写的:
create or replace view depart_employees_view as
select --nvl((select b.name from depart_name_view b where dorder>1 and instr((select a.plist from oa_depart a where a.id = t.fid), ','||b.id||',') <> 0),'广西北海公司') as fgs_name,
nvl((select b.name from depart_name_view b where dorder>1 and instr(','||(select a.plist from oa_depart a where a.id = t.fid), ','||b.id||',') <> 0),nvl((select c.name from depart_name_view c where c.id=(select (case when g.pid>0 then g.pid else g.id end) from oa_depart g where g.id = t.fid)),'广西北海公司')) as fgs_name,
t.id,
t.fid,
t.username,
t.password,
t.partlist,
t.realname,
t.sex,
t.birth,
t.idcard,
t.native,
t.nation,
t.culture,
t.polity,
t.address,
t.zip,
t.homephone,
t.telphone,
t.mobile,
t.email,
t.depart,
t.duty,
t.employtype,
t.postdate,
t.leftdate,
t.memo,
t.fig,
t.bossgh,
t.salemember,
t.disabled,
t.updateuser,
t.updatetime,
t.createuser,
t.createtime
from oa_employees t;
- 查出所有员工所在的分公司sql语句。
- sql面试题:用一条SQL语句查出不重复的所有记录
- SQL语句查出某个用户下所有表, 以及表对应的同义词,主键,索引。
- SQL查出比经理薪水还高的员工信息:
- 一条sql语句查出多个表的数据
- 实验楼sql SELECT 语句详解之查询出各员工所在部门的人数与工程数
- sql查出表的各个字段的所有属性
- 使用SQL视图查出所有的数据库字典
- 使用SQL视图查出所有的数据库字典
- sql 查出一张表中重复的所有记录数据
- SQL查出任意两个数之间的所有数字
- sql 查出一张表中重复的所有记录数据
- sql 查出一张表中重复的所有记录数据
- sql 查出一张表中重复的所有记录数据
- sql 查出一张表中重复的所有记录数据
- sql 查出一张表中重复的所有记录数据
- sql 查出一张表中重复的所有记录数据
- sql 查出一张表中重复的所有记录数据
- CEO、COO、CFO、CTO 各种OO
- 如何隐藏显示在任务栏中的对话框程序
- 关于报applicationContext.xml不存在的问题
- android ril
- 营销感触(三)探听消息要具体
- 查出所有员工所在的分公司sql语句。
- 回顾Microsoft Visual C++ 与 MFC的历史
- 五种JSP页面跳转方法详解
- MySQL查询优化之查询优化器
- struts2中的数据校验文件配置
- SqlParameter
- 我觉得这种思路好,所以把它贴出来
- C++中的内联函数
- TinyXML:一个优秀的C++ XML解析器