带子查询的SQL COUNT函数 [英] Sql COUNT function with a subquery

查看:1372
本文介绍了带子查询的SQL COUNT函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

海,

是否可以在COUNT()函数内编写子查询?

例如:-

我想获得员工人数.

Hai,

Is it possible to write a subquery within the COUNT() function?

For Eg:-

I want to get the count of employees.

select COUNT(select userid from users inner join credit on
             users.userid=credit.userid
             union
             select userid  FROM users inner JOIN jobs
             ON users.userid=jobsuserid)

推荐答案

:omg:
为什么需要外部Count(),只需将查询写为
:omg:
Why you need Count() outside, just write query as
select count(userid)...............


这篇关于带子查询的SQL COUNT函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆