首页 > 解决方案 > 如何在子查询中使用计算字段(sqlite3)

问题描述

我有这个在MySQL中工作的代码

CASE
    WHEN e.sex = 'M' THEN ROUND((salary / 30 * absents) + (salary / 30 / 8 * short_hours * 1.5))
    ELSE ROUND((salary / 30 * absents) + (salary / 30 / 5 * short_hours * 1.5))
END AS deductions,

CASE
    WHEN e.sex = 'M' THEN ROUND(salary / 30 / 8 * overtime * 1.5)
    ELSE ROUND(salary / 30 / 5 * overtime * 1.5)
END AS overtime_bonus,

ROUND(salary - (SELECT deductions) + (SELECT overtime_bonus)) AS total_salary,

我试图让它在SQLite中工作,但我得到了错误no such column: deductions

我的问题是:我可以在 SQLite3 的子查询中使用计算字段吗?

标签: mysqlsqlite

解决方案


推荐阅读