Created
April 23, 2025 15:43
-
-
Save JosephLeedy/a447377f3f198875ad28461666139147 to your computer and use it in GitHub Desktop.
Generate a report of Custom Fees charged by order date
This file contains hidden or 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
SELECT | |
DATE(so.created_at) AS 'Order Date', | |
fee.title AS 'Fee', | |
SUM(fee.base_value) AS 'Base Total Amount', | |
SUM(fee.value) AS 'Total Amount' | |
FROM custom_order_fees AS cof | |
JOIN JSON_TABLE( | |
cof.custom_fees, | |
'$' COLUMNS ( | |
NESTED PATH '$.*' COLUMNS ( | |
title VARCHAR(255) PATH '$.title', | |
value DECIMAL(10, 4) PATH '$.value', | |
base_value DECIMAL(10, 4) PATH '$.base_value' | |
) | |
) | |
) AS fee | |
LEFT JOIN sales_order AS so ON so.entity_id = cof.order_entity_id | |
GROUP BY DATE(so.created_at), fee.title; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment