作业帮 > 英语 > 作业

where e.order_no=f.order_no) g group by cust_id having count

来源:学生作业帮 编辑:大师作文网作业帮 分类:英语作业 时间:2024/11/06 13:34:38
where e.order_no=f.order_no) g group by cust_id having count(distinct prod_id)>=3) h) 为什么要加h?
select a.cust_id,cust_name,b.prod_id,prod_name,d.qty,d.qty*d.unit_price
from customer a,product b,sales c,sale_item d
where a.cust_id=c.cust_id and d.prod_id=b.prod_id and
c.order_no=d.order_no and a.cust_id in (
select cust_id
from (select cust_id,count(distinct prod_id) prod_id
from (select cust_id,prod_id
from sales e,sale_item f
where e.order_no=f.order_no) g
group by cust_id
having count(distinct prod_id)>=3) h)
where e.order_no=f.order_no) g group by cust_id having count
简化后其实是这样的
from (
from () g
) h
h与g都叫做表别名,因为from子句后面()没有明确的表名,
需要添加表别名来让系统识别,h和g分别代表内部的select输出