菜鸟请教一个问题

mq_work 2010-11-19 10:54:34
select count(*) from View_bidui_report_xh where flag='true'

select count(*) from View_bidui_report_xh where department_name='第二组'

请问上述两个查询语句能不能合成一个
就是在查询结果里显示两列
...全文
42 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunlongchina 2010-11-19
  • 打赏
  • 举报
回复
js_szy 的不错 楼上 完全看不懂
dawugui 2010-11-19
  • 打赏
  • 举报
回复
select
(select count(*) from View_bidui_report_xh where flag='true' ),
(select count(*) from View_bidui_report_xh where department_name='第二组')
华夏小卒 2010-11-19
  • 打赏
  • 举报
回复
select
n1=sum(case when flag='true' then 1 else 0 end),
n2=sum(case when department_name='第二组' then 1 else 0 end)
from
华夏小卒 2010-11-19
  • 打赏
  • 举报
回复
select distinct n1=(select count(*) from View_bidui_report_xh where flag='true' ),
n2=(select count(*) from View_bidui_report_xh where department_name='第二组')
from View_bidui_report_xh

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧