我試圖從SUMED列使用下面的查詢基於我的查詢記錄進行排序:MySQL的排序不排序正確的數據
SELECT o.id_customer, CONCAT(c.firstname, ' ', c.lastname) AS 'name',
COUNT(o.id_customer) AS 'repeat', FORMAT(SUM(o.total_products),2) AS 'amount'
FROM ps_orders AS o
LEFT JOIN ps_customer AS c ON o.id_customer = c.id_customer
WHERE o.current_state IN (2,4,5)
AND o.invoice_date BETWEEN '2015-01-01' AND '2015-12-31'
GROUP BY o.id_customer
ORDER BY amount DESC
上面的查詢沒有返回正確的數據,更具體返回的記錄未正確排序。
任何人都可以指向正確的方向嗎?任何幫助深表感謝。
乾杯
你期待什麼,你會得到什麼?你能舉一個例子嗎? – Jacob