某公司的人事系统数据库中有三张表: 员工表(EMP),部门表(DEPT),工资表(SALARY) EMP表结构如下?

某公司的人事系统数据库中有三张表: 员工表(EMP),部门表(DEPT),工资表(SALARY) EMP表结构如下?,第1张

SELECT

main.dept_name as 部门名称,

count(*) as 在职员工数,

sum(acu_salary) as 实发工资总额

FROM

dept main

INNER JOIN emp a ON main.dept_code = a.dept_code

INNER JOIN salary b ON a.emp_id = b.emp_id

WHERE

-- 1为有效标识

main.alive_flag = '1'

AND a.alive_flag = '1'

AND b.alive_flag = '1'

AND b.`month` = '201101'

GROUP BY

a.dept_code

HAVING

count(*) >5

还是如他们所说,要大于等于128

代码如下

oracle的

select

reverse(

chr(case when ascii('a')*2+10>=128 then round((ascii('a')*2+10)/3) else ascii('a')*2+10 end)||

chr(case when ascii('b')*2+10>=128 then round((ascii('b')*2+10)/3) else ascii('b')*2+10 end)||

chr(case when ascii('c')*2+10>=128 then round((ascii('c')*2+10)/3) else ascii('c')*2+10 end)||

chr(case when ascii('d')*2+10>=128 then round((ascii('d')*2+10)/3) else ascii('d')*2+10 end)||

chr(case when ascii('e')*2+10>=128 then round((ascii('e')*2+10)/3) else ascii('e')*2+10 end))

from dual

sqlserver的

select reverse

(

char(case when ascii('a')*2+10>=128 then (ascii('a')*2+10)/3 else ascii('a')*2+10 end)+

char(case when ascii('b')*2+10>=128 then round((ascii('b')*2+10)/3.0,0) else ascii('b')*2+10 end)+

char(case when ascii('c')*2+10>=128 then round((ascii('c')*2+10)/3.0,0) else ascii('c')*2+10 end)+

char(case when ascii('d')*2+10>=128 then round((ascii('d')*2+10)/3.0,0) else ascii('d')*2+10 end)+

char(case when ascii('e')*2+10>=128 then round((ascii('e')*2+10)/3.0,0) else ascii('e')*2+10 end)

)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/10717013.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-10
下一篇 2023-05-10

发表评论

登录后才能评论

评论列表(0条)

保存