本文介绍了从结果查询中选择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(*)
发布评论