Possible to store value of one select column and use it for the next one?
问题 Is it possible to store or cache values that are part of one select column and then be used for the next one? For example, select FirstColumn = (complex query returns a value based on ThirdColumn), SecondColumn = (uses the same value returned from above + does some additional calculations.) from SomeTable Is it possible to do something like that so I don't have to write the same complex query twice? 回答1: You need CROSS APPLY here, it can refer to outer references, no annoying subqueries or