select结果集的再次select 想对查询出来的结果集再次操作,就可以把查询出来的结果集当成⼀个临时表
对临时表t1操作
语法:select  sum(a), b from
( select a, b ,c
from table1
join table2
on table1.a = table2.a
where table1.a='1')  t
group by b
复杂⼀点,对两个临时结果集t1,t2操作
select  sum(a), b from
( select a, b ,c
from table1
join table2
on table1.a = table2.a
where table1.a='1')  t1
join t2
( select a, b ,c
from table1
join table2
on table1.a = table2.a
where table1.a='1')  t2
on t1.a=t2.a
group by b
order by b
tabletable需要注意⼀点的是order by 语句是不能放在内层查询语句的,只能放在外⾯

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。