求完善这条sql语句
有这样一个表,大概有uid,cash,quan,time其中cash,quan为int,现在我想查询按group by date(time)排列的不同uid的总数量,同时想查询按group by date(time)排列的cash>0的uid数量。这是我的错误的sql,谁能给改一下
"select count(select userId from expense group by date(time) having sum(cash)>0),date(time),count(DISTINCT userId),count(id) where time>='"+ startTime + "' and date(time)<='"+ endTime + "' group by date(time)"
select COUNT(uid)from expense group by time having SUM(cash)>0
[解决办法]
建议你提供详细的资料:例如表的结构,表之间的关系,测试数据,相关算法及需要的结果。这样有助于我们理解你的意思,更主要的是能尽快让你获得答案或解决问题的方法。
[解决办法]
select count(distinct userId),sum(case when cash > 0 then 1 else 0 end)from expense group by date(time)
[解决办法]
无数据不回答