Select count(*) from result query

前端 未结 3 1551
一个人的身影
一个人的身影 2021-02-03 17:51

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:

3条回答
  •  梦如初夏
    2021-02-03 18:41

    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
    

    See SQL Fiddle with Demo

    In order for it to work, the count(SID) need a column alias and you have to provide an alias to the subquery itself.

提交回复
热议问题