
CREATE VIEW `view_order_categorywise_details`  AS SELECT `V`.`distributer_id` AS `distributer_id`, `V`.`category_id` AS `category_id`, `V`.`order_month` AS `order_month`, `V`.`order_year` AS `order_year`, sum(`V`.`quantity_ordered`) AS `quantity_ordered`, sum(`V`.`quantity_confirmed`) AS `quantity_confirmed`, sum(`V`.`quantity_shipped`) AS `quantity_shipped`, sum(`V`.`amount_ordered`) AS `amount_ordered`, sum(`V`.`amount_confirmed`) AS `amount_confirmed`, sum(`V`.`amount_shipped`) AS `amount_shipped` FROM `view_order_consolidated_details` AS `V` WHERE ((`V`.`order_date` >= '2024-01-01') AND (`V`.`order_date` <= '2024-06-30')) GROUP BY `V`.`order_year`, `V`.`order_month`, `V`.`distributer_id`, `V`.`category_id` ;



CREATE VIEW `view_order_consolidated_details`  AS SELECT `O`.`month` AS `order_month`, `O`.`year` AS `order_year`, `OD`.`order_date` AS `order_date`, `O`.`distributer_id` AS `distributer_id`, `OD`.`order_id` AS `order_id`, `OD`.`category_id` AS `category_id`, `OD`.`product_id` AS `product_id`, `OD`.`quantity_ordered` AS `quantity_ordered`, `OD`.`quantity_confirmed` AS `quantity_confirmed`, `OD`.`quantity_shipped` AS `quantity_shipped`, ((`OD`.`quantity_ordered` * `OD`.`price`) * `OD`.`exchange_rate`) AS `amount_ordered`, ((`OD`.`quantity_confirmed` * `OD`.`price`) * `OD`.`exchange_rate`) AS `amount_confirmed`, ((`OD`.`quantity_shipped` * `OD`.`price`) * `OD`.`exchange_rate`) AS `amount_shipped` FROM (`ymh_order_details` `OD` left join `ymh_order` `O` on((`O`.`id` = `OD`.`order_id`))) ;
