select category_id, sum(order_amount) as total_sales, sum(if(customer_gender = '男', 1, 0)) as male_customers, sum(if(customer_gender = '女', 1, 0)) as female_customers from order_details left join customer_info using (order_id) where order_date between '2024-01-01' and '2024-06-30' group by category_id order by category_id