Last active
March 15, 2021 10:33
-
-
Save chanakaDe/411901065a4d4230a385e2ffa3920630 to your computer and use it in GitHub Desktop.
Get orders for MS Power BI
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
select orders.id, orders.external_id, orders.created_at, order_items.article_id, manufacturers.name as manufacturer_name, articles.name as article_name, order_items.tariff_id, providers.name as provider_name, tariffs.name as tariff_name,tariffs.commission as tariff_provision, orders.external_status_order,orders.utm_partner, orders.utm_source, articles.cost_price, | |
(SELECT value FROM `property_values` WHERE `item_id` = `articles`.`id` AND `property_type_id` = 2 ) as device_storage, | |
(SELECT value FROM `property_values` WHERE `item_id` = `articles`.`id` AND `property_type_id` = 5 ) as device_color | |
from `orders` inner join `order_items` on `order_items`.`order_id` = `orders`.`id` inner join `articles` on `articles`.`id` = `order_items`.`article_id` inner join `manufacturers` on `manufacturers`.`id` = `articles`.`manufacturer_id` inner join `tariffs` on `tariffs`.`id` = `order_items`.`tariff_id` inner join `providers` on `providers`.`id` = `tariffs`.`provider_id` | |
where year(`orders`.`created_at`) = '2021' and month(`orders`.`created_at`) = '3' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment