记录总结:Oracle子查询语句记录理解

记录一
查询顺序
FROM,WHERE,GROUP BY,SELECT,ORDER BY
(select 只的是查询的指定列)

记录二
子查询
语句理解
select m.*,
(
SELECT o.name orgname
from TREE T, ORGO
where T.PID <> -1 AND T.DAID = O.ID(+) and rownum = 1
start with t.id = m.defpos connect by prior t.PID = t.id
) dename
from (select max(e.cnname) as name,
max(e.defpos ) as defpos ,
max(decode(e.isdel, ‘Y’,‘离职’,‘在职’)) as islizhi,
i.dr as empid,
t.mony as mony,
t.year as biyear,
max(decode(t.clomnt, ‘1’, t.money, null)) as mon1,
max(decode(t.clomnt, ‘2’, t.money,null)) as mon2,
max(decode(t.clomnt,‘3’,t.money,null)) as mon3,
max(decode(t.clomnt,‘4’,t.money,null)) as mon4,
max(decode(t.clomnt, ‘5’, t.money,null)) as mon5,
max(decode(t.clomnt, ‘6’, t.money, null)) as mon6,
max(decode(t.clomnt,‘7’,t.money,null)) as mon7,
max(decode(t.clomnt,‘8’,t.money,null)) as mon8,
max(decode(t.clomnt,‘9’,t.money,null)) as mon9,
max(decode(t.clomnt,‘10’,t.money, null)) as mon10,
max(decode(t.clomnt,‘11’,t.money,null)) as mon11,
max(decode(t.clomnt,‘12’,t.money,null)) as mon12,
sum(t.rebsmoney) as amount
from sub t, ins i, emp e
where i.inid = t.instid and i.dr = e.eid
group by i.dr, t.mony,t.year
order by i.dr) m

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值