select 
    o.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 o
join customer_info c on o.order_id =c.order_id
where order_date between '2024-01-01' and '2024-06-30'
group by 1
order by 1;