私はあなたからの助けが必要です, これは私のSQLクエリです:
select count(SID)
from Test
where Date = '2012-12-10'
group by SID
これは私の結果です:
|2|
|3|
|4|
|3|
そして今、最初のクエリからの結果を数えなければなりません!
Expected result: 4
私はあなたからの助けが必要です, これは私のSQLクエリです:
select count(SID)
from Test
where Date = '2012-12-10'
group by SID
これは私の結果です:
|2|
|3|
|4|
|3|
そして今、最初のクエリからの結果を数えなければなりません!
Expected result: 4
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
In order for it to work, the count(SID)
need a column alias and you have to provide an alias to the subquery itself.
これにより、内部クエリの行がカウントされます。
select count(*) from (
select count(SID)
from Test
where Date = '2012-12-10'
group by SID
) t
ただし、この場合、その効果は次のようになります。
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)
動作するはずです