Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#not_null_order_count
select count(*) not_null_order_count, DATE_FORMAT(orders.created_at, "%Y-%m-%d") as order_date from `orders` inner join `order_items` on `order_items`.`order_id` = `orders`.`id` where exists (select * from `order_items` where `orders`.`id` = `order_items`.`order_id` and exists (select * from `articles` where `order_items`.`article_id` = `articles`.`id` and `manufacturer_id` = ?)) and `order_items`.`tariff_id` is not null and `orders`.`created_at` between ? and ? group by `order_date` order by `order_date` asc
#null_order_count
select count(*) null_order_count, DATE_FORMAT(orders.created_at, "%Y-%m-%d") as order_date from `orders` inner join `order_items` on `order_items`.`order_id` = `orders`.`id` where exists (select * from `order_items` where `orders`.`id` = `order_items`.`order_id` and exists (select * from `articles` where `order_items`.`article_id` = `articles`.`id` and `manufacturer_id` = ?)) and `order_items`.`tariff_id` is null and `orders`.`created_at` between ? and ? group by `order_date` order by `order_date` asc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment