SELECT COUNT(DISTINCT(ccc)) AS ccc,COUNT(DISTINCT(bbb)) AS bbb FROM total WHERE user_id='$user_id' AND ADDDATE BETWEEN '$time[starttime]' AND '$endtime' GROUP BY aaa ORDER BY aaa DESC
Die SQL-Anweisung ist wie oben. Kann mir jemand einen Rat geben?
考虑使用MongoDB的aggregation:
1、COUNT(DISTINCT(ccc)) AS ccc,COUNT(DISTINCT(bbb)) AS bbb
$group+$sum
2、user_id='$user_id' AND ADDDATE BETWEEN '$time[starttime]' AND '$endtime'
$match
供参考。
Love MongoDB!Have fun!