比较快的写法是什么
我现在用left join 这个表本身,但是结果好像不对
SELECT
table.id ,SUM(table.s-yestoday.a) as sum
FROM table
LEFT JOIN table yestoday
ON yestoday.uid = wy_appdata.uid
WHERE table.year = '.$year.' AND table.month = '.$month.' AND table.day = '.$day.' AND yestoday.year = '.$bre_data['year'] .' AND yestoday.month ='.$bre_data['month'] .' AND yestoday.day = '.$bre_data['day'] .'
GROUP BY table.uid
ORDER BY sum DESC
假设有如下数据表
tbl
运行
结果