mysql 子查询 from之后子查询出错

问题遇到的现象和发生背景

mysql 8.0.21版本

用代码块功能插入代码,请勿粘贴截图

select e.ename,e.sal,t.* from(select deptno,avg(sal) as salavg from emp group by deptno) as t join emp e on t.deptno=e.deptno and e.sal>t.salavg;

运行结果及报错内容

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from(select deptno,avg(sal) as salavg from emp group by deptno) as t join emp ' at line 1

我的解答思路和尝试过的方法

但是将子查询的内容放到join后可以正确输出,例如:
select t.*,e.ename,e.sal from emp e join (select deptno,avg(sal) as salavg from emp group by deptno) t on e.deptno=t.deptno and e.sal>t.salavg;
结果为:

| deptno | salavg | ename | sal |

| 30 | 1566.666667 | ALLEN | 1600.00 |
| 20 | 2175.000000 | JONES | 2975.00 |
| 30 | 1566.666667 | BLAKE | 2850.00 |
| 20 | 2175.000000 | SCOTT | 3000.00 |
| 10 | 2916.666667 | KING | 5000.00 |
| 20 | 2175.000000 | FORD | 3000.00 |

我想要达到的结果

请问,究竟什么原因导致from后select子查询出错?

这个是中文括号吧?后边报错就是这附近错误

img