SELECT COUNT(wo.id), wm.*
FROM webshop_orders as wo
LEFT JOIN webshop_merchants as wm ON wo.merchant_id = wm.id
LEFT JOIN webshop_merchant_order mo ON mo.merchant_id = wm.id AND mo.language_id = 1
WHERE (mo.hidden = 0) AND wm.status = 1
AND DATE(wo.created_at) > CURDATE() - INTERVAL 1 MONTH
GROUP BY wo.merchant_id
ORDER BY COUNT(wo.id) DESC
I am selecting last month orders
most used payment method and filtering the most used ones at the top of the list on the payment method page. The only problem i am now facing is that when a payment method doesn’t get used for example an entire month it will skip the payment method and not show it.
My question is does somebody have a good example of this kind of problem because i cant find a good one on stackoverflow.
2
Answers
I have made some changes to my query and it works know.
results
Have you tried changing the first WHERE statement (
(mo.hidden = 0)
)with: