编辑:在此查询中完成一个小的修改。 那就是我需要以下列格式显示结果:
1。其中totalDealsBought小于maxBuy应显示为FIRST。
如何做到这一点?
SELECT d.id, d.dealTitle, d.expiryDate, d.dealMainImage, d.actualPrice, d.discount, d.offerValue, d.maxBuy, sum( sc.quantity ) AS totalDealsBought
FROM deal AS d
LEFT JOIN shoppingcart AS sc ON sc.dealID = d.id
WHERE CURDATE( ) != d.startDate
AND d.startDate < CURDATE( )
AND d.status = 'Active'
AND d.cities = 'chennai'
AND sc.paymentStatus = 'paid'
GROUP BY d.id
提前致谢。
答案 0 :(得分:0)
... AND sc.paymentStatus = 'paid'
GROUP BY d.id
ORDER BY totalDealsBought, maxBuy
答案 1 :(得分:0)
... GROUP BY d.id
ORDER BY (totalDealsBought < d.maxBuy) DESC