34,837
社区成员




select COUNT(DISTINCT(userid)) from table
select time as 日期
,SUM(case when userType=1 then 1 else 0 end) as user1数量
,SUM(case when userType=1 then money else 0 end) user1money
,SUM(case when userType=2 then 1 else 0 end) as user2数量
,SUM(case when userType=2 then money else 0 end) user2money
from tb
group by time
select userType,time as 日期,count(1) as 数量,sum(money)money
from tb where userType=1
group by userType,time
select CONVERT(VARCHAR(19),time,111) as 日期,
SUM(case when userType=1 then money else 0 end) as userType=1的money
from table
group by CONVERT(VARCHAR(19),time,111)
请问 userType=1的用户数 的数据怎么求?