是否可以从 MYSQL 中的两个别名的其余部分创建第三个别名?
这是我的查询:
SELECT DISTINCT
workcards.task,
workcards.program,
workcards.zone,
workcards.CYLcomp,
workcards.CYLint,
workcards.task,
workcards.CYLcomp + workcards.CYLint AS nextdue,
workcards.wcnumber,
(SELECT airtimes.total_cycles
FROM airtimes
WHERE airtimes.nnumber='xxxxx'
ORDER BY airtimes.total_cycles DESC LIMIT 1) AS current_cycle
FROM workcards
WHERE basis LIKE '%CYL%'
AND nnumber='xxxxx'
ORDER BY CASE nextdue
WHEN 0 THEN 1 ELSE -1 END ASC, nextdue ASC
我想要做的是创建第三个别名,这将是“nextdue”减去“current_cyle”别名的区别?就像是:
nextdue - current_cycle AS remainder?
对不起,如果noob或其他什么。
谢谢