For example, my query is something like:
SELECT fullName = firstName + ' ' + middleName + ' ' + lastName,
streetAddress = address1
FROM Person
How would I be able to reference fullName directly without having to type out first+middle+last again? If I just added "WHERE fullName = 'John X Doe'", i get the error that fullName is an invalid column.
I've tried throwing it into a variable
SELECT @fullNameVar = firstName + ' ' + middleName + ' ' + lastName,
fullName = @fullNameVar
streetAddress = address1
FROM Person
WHERE @fullNameVar = 'John X Doe'
but I cannot use a select statement to set a variable when I am also retrieving other data.