SQL 报错:缺少别名 - SELECT *, RANK() OVER (ORDER BY z.rate DESC) AS rank
这段 SQL 语句缺少一个别名,应该在最后一行添加别名。例如,添加别名为't':
SELECT , RANK() OVER (ORDER BY z.rate DESC) AS rank from ( select k.identity_role As role, k.quilified / k.total As rate from (select x.identity_role, x.quilified, h.total from (select s.identity_role, count() As quilified from (select n.id, p.identity_role from pmis.busi_project_person p left join (select p.id, count() As total from pmis.busi_project_person p left join pmis.busi_attendance a on p.id = a.person_id where p.del_flag = 0 and a.card_date BETWEEN DATE_SUB(DATE_SUB(LAST_DAY(NOW()), INTERVAL 1 MONTH), INTERVAL DAY(LAST_DAY(NOW())) - 1 DAY) AND DATE_SUB(LAST_DAY(NOW()), INTERVAL 1 MONTH) group by p.id) n on p.id = n.id where n.total > p.date) s where s.identity_role != 1 group by s.identity_role) x left join (select p.identity_role, count() As total from pmis.busi_project_person p where p.del_flag = 0 group by p.identity_role) h on h.identity_role = x.identity_role) )As z) AS t
原文地址: https://www.cveoy.top/t/topic/mSId 著作权归作者所有。请勿转载和采集!