Let's say I have this query:`
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
So in this example I have more that 1 alias and I want to use some of them inside other aliases , Like a nested aliases.
How to achieve that without copying/pasting alias inside another alias like:
IF(
IF(dCheck="Yes", "Great", "Not Great") AS firstNested) ="Great",1,0
) AS secondNested
Note sure if the above is a right syntax.
Try this:
Bug:
dCheck
result will beY
orN
and you are checkingYes
in the next test which will result false andfirstNested
will beNot Great
for all the rows.Your query should be: