How do I refer to an AS statement with a space later in the Query

So if I run

SELECT full_name AS 'Full Name', sum(age) AS 'Years Old' FROM friends;

I understand the sum(age) makes no sense, but I’m using it as an example here. If I want to reference the sum(age) in my WHERE clause I can do it 2 was. The first way is to write

WHERE sum(age) > 21;

The other I know is to remove the space in my as statement.

SELECT full_name AS 'Full Name', sum(age) AS 'yearsOld' FROM friends
WHERE yearsOld > 21;

Is there a way to reference ‘Years Old’ in the WHERE statement?

given spaces are used for argument separation, its just bad practice to have spaces in your name fields or aliases. Even if it was possible, you would need a very good reason to do so (by which i mean: that reason is nearly non-existing)

1 Like

Thank you, was really just curious if it was possible.