I have the following query:
select FirstName, LastName,
Case
When LastName = 'Jones'
then 'N/A'
End as Other,
Case
When Other is not null
then 1
else 0 as Flag
The Flag value depends on Other but as Other is an alias, the Flag field does not recognize Other.
I guess, I can use a select within a select. Is there a better way for Flag to recognize the Other alias column?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…