请问大家为什么在mysql中报“every deriver table must have its own alias”错误。请大家麻烦找出错误。谢谢!
select * from(
select pp.name,pp.m1,pp.m2,pp.m3,pp.m4,pp.m5,pp.m6,pp.m7,pp.m8,pp.m9,pp.m10,pp.m11,pp.m12, IfNull(pp.m1,0)+IfNull(pp.m2,0)+IfNull(pp.m3,0)+IfNull(pp.m4,0)+IfNull(pp.m5,0)+IfNull(pp.m6,0)+IfNull(pp.m7,0)+IfNull(pp.m8,0)+IfNull(pp.m9,0)+IfNull(pp.m10,0)+IfNull(pp.m11,0)+IfNull(pp.m12,0) totle
from (select a2.depname name,
sum(case when a2.month='1' then a2.totle else 0 end) m1,
sum(case when a2.month='2' then a2.totle else 0 end) m2,
sum(case when a2.month='3' then a2.totle else 0 end) m3,
sum(case when a2.month='4' then a2.totle else 0 end) m4,
sum(case when a2.month='5' then a2.totle else 0 end) m5,
sum(case when a2.month='6' then a2.totle else 0 end) m6,
sum(case when a2.month='7' then a2.totle else 0 end) m7,
sum(case when a2.month='8' then a2.totle else 0 end) m8,
sum(case when a2.month='9' then a2.totle else 0 end) m9,
sum(case when a2.month='10' then a2.totle else 0 end) m10,
sum(case when a2.month='11' then a2.totle else 0 end) m11,
sum(case when a2.month='12' then a2.totle else 0 end) m12
from ( select a.month,a1.depname,a1.totle from tbl_month_of_year a left join
(SELECT t3.moth,
t3.depname,
COUNT(t3.depname) totle
FROM (SELECT date_format(tt.fabutime, '%m') moth,
t2.depname
FROM (SELECT t.fabutime,
t.loginuser,
t1.depid
FROM tbl_info t
INNER JOIN tbl_base_dep_user t1 ON t.loginuser =
t1.loginuser
AND t.state = 'FB'
AND t.siteroot ='whct'
AND date_format(t.fabutime, '%Y') =
date_format(sysdate(), '%Y')) tt
INNER JOIN tbl_base_department t2 ON tt.depid = t2.depid) t3
GROUP BY t3.moth,
t3.depname) a1 on a.month =a1.moth ) a2 where a2.depname is not null group by a2.depname) pp
)kk
union all
select * from( select '<div style=color:red; font-weight:bold;>总计</div>' name,
sum(m1) m1,sum(m2) m2,sum(m3) m3,sum(m4) m4,sum(m5) m5,sum(m6) m6,sum(m7) m7,sum(m8) m8,sum(m9) m9,sum(m10) m10,sum(m11) m11,sum(m12) m12,sum(totle) tole from
( select pp.name,pp.m1,pp.m2,pp.m3,pp.m4,pp.m5,pp.m6,pp.m7,pp.m8,pp.m9,pp.m10,pp.m11,pp.m12, IfNull(pp.m1,0)+IfNull(pp.m2,0)+IfNull(pp.m3,0)+IfNull(pp.m4,0)+IfNull(pp.m5,0)+IfNull(pp.m6,0)+IfNull(pp.m7,0)+IfNull(pp.m8,0)+IfNull(pp.m9,0)+IfNull(pp.m10,0)+IfNull(pp.m11,0)+IfNull(pp.m12,0) totle
from (select a2.depname name,
sum(case when a2.month='1' then a2.totle else 0 end) m1,
sum(case when a2.month='2' then a2.totle else 0 end) m2,
sum(case when a2.month='3' then a2.totle else 0 end) m3,
sum(case when a2.month='4' then a2.totle else 0 end) m4,
sum(case when a2.month='5' then a2.totle else 0 end) m5,
sum(case when a2.month='6' then a2.totle else 0 end) m6,
sum(case when a2.month='7' then a2.totle else 0 end) m7,
sum(case when a2.month='8' then a2.totle else 0 end) m8,
sum(case when a2.month='9' then a2.totle else 0 end) m9,
sum(case when a2.month='10' then a2.totle else 0 end) m10,
sum(case when a2.month='11' then a2.totle else 0 end) m11,
sum(case when a2.month='12' then a2.totle else 0 end) m12
from ( select a.month,a1.depname,a1.totle from tbl_month_of_year a left join
(SELECT t3.moth,
t3.depname,
COUNT(t3.depname) totle
FROM (SELECT date_format(tt.fabutime, '%m') moth,
t2.depname
FROM (SELECT t.fabutime,
t.loginuser,
t1.depid
FROM tbl_info t
INNER JOIN tbl_base_dep_user t1 ON t.loginuser =
t1.loginuser
AND t.state = 'FB'
AND t.siteroot ='whct'
AND date_format(t.fabutime, '%Y') =
date_format(SYSDATE, '%Y')) tt
INNER JOIN tbl_base_department t2 ON tt.depid = t2.depid) t3
GROUP BY t3.moth,
t3.depname) a1 on a.month =a1.moth ) a2 where a2.depname is not null group by a2.depname) pp) )kk
请问大家为什么在mysql中报“every deriver table must have its own alias”错误。请大家麻烦找出错误。谢谢!