gpt4 book ai didi

mysql - 在having 子句中使用运算符。错误

转载 作者:行者123 更新时间:2023-11-29 17:31:32 26 4
gpt4 key购买 nike

set @mte := (select max(salary * months) from employee);

select count(name), salary*months
from employee
group by salary*months
having salary*months = @mte;

编译时出现错误

ERROR 1054 (42S22) at line 12: Unknown column 'salary' in 'having clause' P.S: Woud like to use having clause instead of where. I'm learning through experimenting. Would like to know why this doesn't works P.S: USING MYSQL LATEST

最佳答案

尝试在此处使用交叉应用并用 where 子句替换having:

set @mte := (select max(salary * months) from employee);

select count(name), SalMonth
from employee cross apply (select salary*months SalMonth)a
where SalMonth = @mte
group by SalMonth;

关于mysql - 在having 子句中使用运算符。错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50591677/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com