Every derived table must have its own alias(sql语句错误解决方法)

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

例如:

select class from (select class,count(distinct student) as num from Courses group by class)  where num>=5;
就要给派生出来的表起一个别名

修改后的sql,直接在新生产的表中加入别命名就行(“as temp”或者“temp”),“temp”为新表的别名

select class from (select class,count(distinct student)  num from Courses group by class) as temp where num>=5;
 
posted @ 2022-09-05 00:59  口袋饱饱  阅读(200)  评论(0)    收藏  举报