LeetCode1571-仓库经理

将两个表相关联,然后将相同类别进行分组,分组之后再进行聚合,聚合中完成运算

# Write your MySQL query statement below
select
    distinct w.name as `WAREHOUSE_NAME`,
    sum(t.v*w.units) as `VOLUME`
from
    Warehouse as `w` 
    join
    (

        select
            product_id,
            Width*Length*Height `v`
        from 
            Products
    ) as `t` 
    on w.product_id = t.product_id
group by w.name
posted @ 2022-05-07 14:13  Lazy_tiger  阅读(22)  评论(0编辑  收藏  举报