SQL 同一张表俩条查询相同字段的语句不同结果合并成一条语句,输出所有字段信息
selectA0190as'工号',A0101as'姓名',C2108AS'应发',C211HAS'实发'fromC21wheregz_ym='201904'anda01...
select A0190 as '工号', A0101 as '姓名',C2108 AS '应发',C211H AS '实发'from C21 where gz_ym = '201904' and a0188 not in (select a0188 from C21 where gz_ym= dbo.ym_s('201904') and a0191 not in ('黑名单','外包工'))and a0191 not in ('黑名单','外包工')
select A0190 as '工号', A0101 as '姓名',C2108 AS '应发',C211H AS '实发'from C21 where gz_ym= dbo.ym_s('201904') and a0188 not in (select a0188 from C21 where gz_ym = '201904' and a0191 not in ('黑名单','外包工'))and a0191 not in ('黑名单','外包工') 展开
select A0190 as '工号', A0101 as '姓名',C2108 AS '应发',C211H AS '实发'from C21 where gz_ym= dbo.ym_s('201904') and a0188 not in (select a0188 from C21 where gz_ym = '201904' and a0191 not in ('黑名单','外包工'))and a0191 not in ('黑名单','外包工') 展开
2个回答
展开全部
select A0190 as '工号', A0101 as '姓名',C2108 AS '应发',C211H AS '实发'from C21 where gz_ym = '201904' and a0188 not in (select a0188 from C21 where gz_ym= dbo.ym_s('201904') and a0191 not in ('黑名单','外包工'))and a0191 not in ('黑名单','外包工') union all
select A0190 as '工号', A0101 as '姓名',C2108 AS '应发',C211H AS '实发'from C21 where gz_ym= dbo.ym_s('201904') and a0188 not in (select a0188 from C21 where gz_ym = '201904' and a0191 not in ('黑名单','外包工'))and a0191 not in ('黑名单','外包工')
select A0190 as '工号', A0101 as '姓名',C2108 AS '应发',C211H AS '实发'from C21 where gz_ym= dbo.ym_s('201904') and a0188 not in (select a0188 from C21 where gz_ym = '201904' and a0191 not in ('黑名单','外包工'))and a0191 not in ('黑名单','外包工')
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询