从结果查询中选择count(*) [英] Select count(*) from result query
本文介绍了从结果查询中选择count(*)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要您的帮助,这是我的SQL查询:
I need help from you, this is my sql query:
select count(SID)
from Test
where Date = '2012-12-10'
group by SID
这是我的结果:
|2|
|3|
|4|
|3|
现在我必须计算第一个查询的结果!
and now I have to count the results from first query!
Expected result: 4
推荐答案
您可以将查询包装在另一个SELECT
中:
You can wrap your query in another SELECT
:
select count(*)
from
(
select count(SID) tot -- add alias
from Test
where Date = '2012-12-10'
group by SID
) src; -- add alias
请参见带有演示的SQL小提琴
为使其正常工作,count(SID)
需要一个列别名,并且您必须为子查询本身提供一个别名.
In order for it to work, the count(SID)
need a column alias and you have to provide an alias to the subquery itself.
这篇关于从结果查询中选择count(*)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文