mysql怎樣查詢日期,mysql中按照日期分組查詢數量?
SELECT DATE_FORMAT(time,'%Y-%m-%d') as day, sum(case when amount>0 then amount when amount=0 then 0 end) as amount1from table where time>='2014-11-01' group by day;我沒有測試。time表示日期,amount表示數量。查詢11月后每天成交數量
SELECT DATE_FORMAT(time,'%Y-%m-%d') as day, sum(case when amount>0 then amount when amount=0 then 0 end) as amount1from table where time>='2014-11-01' group by day;我沒有測試。time表示日期,amount表示數量。查詢11月后每天成交數量