SELECT `sm`.`productId` AS `productId`, `sm`.`id` AS `movement_id`, `sm`.`type` AS `type`, `sm`.`quantity` AS `quantity`, `sm`.`fee` AS `fee`, `sm`.`totalCost` AS `totalCost`, `sb`.`quantity` AS `balance_quantity`, `sb`.`avgCost` AS `balance_avg_cost`, `sm`.`createdAt` AS `createdAt` FROM ( `pos`.`Stock_Movements` `sm` LEFT JOIN `pos`.`stock_balance` `sb` ON((`sb`.`ProductId` = `sm`.`productId`)) ) ORDER BY `sm`.`productId`, `sm`.`createdAt`