引用子查询变量

时间:2016-09-01 15:48:42

标签: mysql sql

我有这样的查询

(select max(mon_sal.(salary)) from 
(select salary from employee group by employee_id) as mon_sal) 

而在上面的查询中,我使用 mon_sal.salary 来引用子查询变量。

问题从这里开始:

但现在同样我需要引用以下变量

(select max(mon_sal.(month*salary)) from 
(select month*salary from employee group by employee_id) as mon_sal) as max_mon_sal

我想在子查询中使用乘法运算符引用两个变量,我无法引用子查询变量。

请建议。

1 个答案:

答案 0 :(得分:0)

您可以使用别名

(select max(mon_sal.(my_alias)) from  (
       select distinct  month*salary as my_alias 
       from employee  )   mon_sal)    max_mon_sal
相关问题