2020
10-08
10-08
两种方法实现mysql分组计数,范围汇总
第一种:常规操作SELECTSUM(ddd)AScount_days,CASEWHENaa.days>=1ANDaa.days<3THEN'1-3'WHENaa.days>=3ANDaa.days<5THEN'5-3'ELSE'5+'ENDASgroupby_daysFROM(SELECTSUM(1)ASddd,daysFROMtour_groupGROUPBYdays)ASaaGROUPBYgroupby_days;第二种:真香函数SELECTelt(INTERVAL(days,1,3,5,7,10),"1-3","3-5","5-7","7-10",...
继续阅读 >