如上圖所示, 用到的字段 有 uid(用戶id) ?pid(直接推薦人ID) ?ppid(間接推薦人ID) ?fen(銷售份數(shù)) ?addtime(購買的時(shí)間)要求為統(tǒng)計(jì)所有 pid ppid uid 的銷售份數(shù)總和按時(shí)間段來排序.說明 三級(jí)分銷的業(yè)績是累加的. 也就是要把這個(gè)表中所有 pid,ppid,uid為同一個(gè)id值的時(shí)候統(tǒng)計(jì)出銷售份數(shù)之和,并排序.想問下這個(gè)能實(shí)現(xiàn)么. (目前僅能得到單個(gè)字段的統(tǒng)計(jì)結(jié)果)$time1 $time2 是起止時(shí)間"SELECT uid,SUM(fen) as fen FROM yh_sales WHERE addtime BETWEEN $time1 AND $time2 ?GROUP BY 1 ?ORDER BY 2 DESC LIMIT 0 , 5"
請(qǐng)教大家一個(gè)三級(jí)分銷業(yè)績統(tǒng)計(jì)的MySQL查詢語句問題
愿夜幕永不開啟
2017-09-23 19:53:20