Created
July 10, 2014 07:33
-
-
Save benjamintanweihao/1eb77356dcd63938ac3f to your computer and use it in GitHub Desktop.
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 locations.name, SUM(items.count_on_hand) AS stock_count, SUM(items.count_on_hand * prices.amount) AS total_price | |
| FROM spree_stock_locations AS locations | |
| INNER JOIN spree_stock_items AS items | |
| ON locations.id = items.stock_location_id | |
| INNER JOIN spree_variants AS variants | |
| ON variants.id = items.variant_id | |
| INNER JOIN spree_prices AS prices | |
| ON prices.variant_id = variants.id | |
| WHERE prices.currency = 'SGD' | |
| GROUP BY (locations.id) | |
| ORDER BY name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment