# 不同欸别商品 销售情况 性别分布

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

select * from t1