我有这样的疑问:
SELECT
IF(daycode=1,(SELECT...),(SELECT...)) AS weekavg,
(SELLOFF1 / weekavg) AS procent
FROM .....
它告诉我:Unknown column 'weekavg' in 'field list'
,这是在我添加了除法之后发生的,之后就可以了。
答案 0 :(得分:1)
您可以使用子查询:
SELECT (selloff1 / weekavg) AS procent
FROM (
SELECT
selloff1, IF(daycode=1,(SELECT...),(SELECT...)) AS weekavg
FROM ...
)