帮我整体分析和讲解下以下 SQL语句(ORACLE中的),给50分~~~

select c.dsc 订货方式,count(distinct a.orderid) 订单总数,d.orid 成功订单总数,h.gnum 成功订货款 ,decode(count(distinct a.orderid),0,0,to_char(d.orid/count(distinct a.orderid),'0D999')) 订单成功率 from orderhist a,names c, orderdet y, (select f.dsc fdsc,COUNT(distinct e.orderid) orid from orderhist e,names f,orderdet x where e.orderid=x.orderid and e.status = '5' and e.mailtype = f.id and f.TID = 'BUYTYPE' and trunc(e.crdt) between to_date('^1','yyyy-mm-dd') and to_date('^2','YYYY-MM-DD') and x.soldwith in ('1','2','3') --and e.ordertype in (select id from names where tid = 'ORDERTYPE' and dsc = '^3') group by f.dsc) d, (select f.dsc hdsc, sum(g.uprice*g.upnum + g.sprice * g.spnum) gnum from orderhist e,names f,orderdet g

第1个回答  2020-03-21
select:
查询
c.dsc
订货方式:
c表的dsc字段
显示字段名字为
订货方式
count():聚合函数
统计数量的
distinct
:消除重复的
from
orderhist
a,names
c,
orderdet
y:要查询的表
orderhist表在这条语句中命名为a
where
:条件
between
and
:在这2个时间内
x.soldwith
in
('1','2','3'):x表soldwith
字段的值是1
2
3的
group
by
:分组显示
sum():聚合函数
字段的值的和
相似回答