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_pricefrom customer a,product b,sales c,sale_item dwhere a.cust_id=c.cust_id and d

来源:学生作业帮助网 编辑:六六作业网 时间:2024/05/10 00:35:32
wheree.order_no=f.order_no)ggroupbycust_idhavingcount(distinctprod_id)>=3)h)为什么要加h?selecta.cust_id,c

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_pricefrom customer a,product b,sales c,sale_item dwhere a.cust_id=c.cust_id and d
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(distinct prod_id)>=3) h) 为什么要加h?select a.cust_id,cust_name,b.prod_id,prod_name,d.qty,d.qty*d.unit_pricefrom customer a,product b,sales c,sale_item dwhere a.cust_id=c.cust_id and d
简化后其实是这样的
from (
from () g
) h
h与g都叫做表别名,因为from子句后面()没有明确的表名,
需要添加表别名来让系统识别,h和g分别代表内部的select输出