20151204工作中用到的查询语句

时间:2023-01-12 08:11:57
/*删除工资记录为空的人员信息*/
delete from GZ_RY_JBXX where rybm not in(
select distinct rybm from GZ_RY_GZJL)

delete from GZ_DW_DWXX where DWBM='1111111111'
/*查询单位编码为1111111111的单位的人员个数*/
select COUNT(0) from GZ_RY_JBXX where DWBM='1111111111'

/**/
select q.GZSFBM,q.DQZWBM,right(q.DQZWBM,2) HLW,q.GWDJ,q.XJ,q.RYBM,r.JSSJ
into #tempRY
from dbo.GZ_DW_DWXX AS d
INNER JOIN dbo.GZ_RY_JBXX AS r ON d.DWBM = r.DWBM
and d.SSQY='3601000000'
and d.DWZT='1'
and r.RYGLFS='2001'
inner join dbo.View_DQLSXX q on r.DWBM=q.DWBM and r.RYBM=q.RYBM
and q.TJYF='201412'
and q.GZSFBM in('22');


select * from #tempRY where GWDJ=13 and XJ=10 and DQZWBM!='220006'


//事业单位分行业统计
select * from gz_sys_hylb
--where hy_mc='其他行业'

select distinct unitno,hy_id
from v_danw_reny_xinx_gz06
where catano in ('21','22','23','24')
and ((state = '01' or state = '02') or (state > '02' and chgdate >= '201412'))
and niany='201412' and renyxz='2001' and (quhdm = '3601000000')
and unitno not in(
select distinct d.DWBM
from dsrsgz5_NB.dbo.GZ_DW_DWXX AS d
INNER JOIN dsrsgz5_NB.dbo.GZ_RY_JBXX AS r ON d.DWBM = r.DWBM
and d.SSQY='3601000000'
and d.DWZT='1'
and r.RYGLFS='2001'
inner join dsrsgz5_NB.dbo.View_DQLSXX q on r.DWBM=q.DWBM and r.RYBM=q.RYBM
and q.TJYF>='201401' and q.TJYF<='201412'
and q.DQZWBM like '2%'
where SSHY='015' and TJYF='201412'
)