Last active
December 29, 2022 14:15
-
-
Save webdawe/f8dbaa790ecb91b318f2517a40c2a7b0 to your computer and use it in GitHub Desktop.
Query for retrieving country wise sales report from Magento Database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET @fromDate = DATE_SUB(NOW(), INTERVAL 1 YEAR); | |
SELECT country_id, count(*) as total_orders,SUM(s.grand_total) | |
FROM `sales_flat_order_address` a | |
INNER JOIN sales_flat_order s ON s.entity_id = a.parent_id | |
WHERE s.created_at >= @fromDate | |
AND a.address_type = 'shipping' | |
GROUP BY country_id | |
ORDER BY total_orders DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment