假设我有一个问题:`
SELECT
IF(uPer="Yes", "Y", "N") AS Manage,
IF(date_check="Yes", "Y", "N") As dCheck,
IF(dCheck="Yes", "Great", "Not Great") AS firstNested,
IF(firstNested="Great",1,0) AS secondNested
FROM table
所以在这个例子中,我有不止一个别名,我想在其他别名中使用其中的一些,比如嵌套的别名。
如何在不将别名复制/粘贴到另一个别名(如:
IF(
IF(dCheck="Yes", "Great", "Not Great") AS firstNested) ="Great",1,0
) AS secondNested
请注意,如果以上是正确的语法。
1条答案
按热度按时间lkaoscv71#
试试这个:
缺陷:
dCheck
结果将是Y
或者N
你在检查吗Yes
在下一个测试中,哪个结果是假的firstNested
将Not Great
所有的行。您的查询应该是: