Skip to content

Instantly share code, notes, and snippets.

@chanakaDe
Last active Mar 15, 2021
Embed
What would you like to do?
Get orders for MS Power BI
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