在做多表查询,或者查询的时候产生新的表的时候会出现这个错误:Every derived table must have its own alias(每一个派生出来的表都必须有一个自己的别名)。

解决:在括号外面给嵌套的中间表起一个表面

SELECT COUNT(1)FROM (
        SELECT d.workShop,COUNT(1) AS carNum,SUM(d.checkWeight) AS allCheckWeight
        FROM tb_alliq_weigh_record d
        WHERE 1=1 AND d.isDelete=0 AND d.status=3
        GROUP BY d.workShop
        ) AS T;