Mysql报错“every deriver table must have its own alias”

请问大家为什么在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”错误。请大家麻烦找出错误。谢谢!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值