I need help from you, this is my sql query:
select count(SID)
from Test
where Date = '2012-12-10'
group by SID
this is my result:
|2|
|3|
|4|
|3|
and now I have to count the results from first query!
Expected result: 4
This question is related to
sql
sql-server
select
This counts the rows of the inner query:
select count(*) from (
select count(SID)
from Test
where Date = '2012-12-10'
group by SID
) t
However, in this case the effect of that is the same as this:
select count(distinct SID) from Test where Date = '2012-12-10'
select count(*) from(select count(SID) from Test where Date = '2012-12-10' group by SID)
select count(*) from(select count(SID) from Test where Date = '2012-12-10' group by SID)
should works
Source: Stackoverflow.com