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 ('黑名单','外包工')
展开
 我来答
华夏日长兴
2019-08-20 · TA获得超过9592个赞
知道大有可为答主
回答量:6305
采纳率:85%
帮助的人:3735万
展开全部
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 ('黑名单','外包工')
帐号已注销
2019-08-20 · TA获得超过149个赞
知道小有建树答主
回答量:291
采纳率:67%
帮助的人:58.7万
展开全部
最简单的办法是两条sql语句之间用【union】连接
或者是where条件用【or】来连接
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式