# 库存数量小于10,销售额超过5000
with
t1 as(
select
store_id,
product_id,
inventory_quantity,
sales_amount
from
sales_inventory
where
inventory_quantity<10 and sales_amount>5000
)
,
t2 as(
select
store_id,
store_name,
product_category,
inventory_quantity,
sales_amount
from
t1
left join products using(product_id)
left join stores using(store_id)
order by
store_id,
product_id
)
select * from t2

京公网安备 11010502036488号