select 
tbl_products.code as Code_style_10_left
,tbl_products.name as Product_style_30_left
,tbl_products.description as Description_style_20_left
, count(tbl_sale_invoice_products.product_id)  as Sale_Count_style_10_right
, sum(tbl_sale_invoice_products.qty)  as Sale_Qty_style_10_right
, ROUND(ifnull(tbl_inventory.qty_in_stock,0) ,2) as Avaiable_count_style_10_right
, ROUND(ifnull(tbl_product_details.field_value,0),2)  as Reorder_count_style_10_right
from tbl_sale_invoice_products
inner join tbl_sale_invoice on tbl_sale_invoice.id = tbl_sale_invoice_products.sale_invoice_id
and tbl_sale_invoice.status in ('4','102')
inner join tbl_products on tbl_products.product_id = tbl_sale_invoice_products.product_id
left join tbl_inventory on tbl_inventory.product_id = tbl_sale_invoice_products.product_id
left join tbl_product_details on tbl_product_details.parent_id = tbl_sale_invoice_products.product_id
and tbl_product_details.field_name in ('reorder_qty')
where tbl_sale_invoice_products.created_on between '{fromDate}' and '{toDate}' 
and (tbl_products.category_id = {category_id} or {category_id} = 0)
group by tbl_sale_invoice_products.product_id
order by count(tbl_sale_invoice_products.product_id) desc