A SELECT-list alias names a result expression, and it is not available to every clause. Under the documented logical binding model, WHERE is considered before SELECT, so it cannot use an alias created in the SELECT list. ORDER BY follows SELECT and can use that output name. This is a rule about name availability—not a claim that the database physically executes each clause in that order.
Why can’t I use a SELECT alias in WHERE?
Consider this query:
SELECT price * quantity AS total
FROM line_items
WHERE total > 100;
total is the output-column alias for the expression price * quantity. In SQL Server’s documented logical order, WHERE comes before SELECT. The alias therefore has not been introduced as an output name when WHERE is bound. MySQL 8.4 states the same restriction: a SELECT alias cannot be referenced in WHERE because the column value might not yet be determined when that clause is executed. MySQL 8.4 Reference Manual: SELECT Statement.
As an Amazon Associate I earn from qualifying purchases.
This concerns a SELECT-list alias, not a table alias declared in FROM. The two kinds of aliases have different roles and visibility rules.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Filter using the input expression
For a row-level filter, repeat the expression in WHERE:
#1 Best Overall
SELECT price * quantity AS total
FROM line_items
WHERE price * quantity > 100;
This makes the filter depend on input columns rather than the output name. It does not imply that the expression is physically calculated a particular number of times; the optimizer determines the physical plan.
Make the computed name an input to an outer query
A subquery creates a query boundary. Its output column becomes an input column visible to the outer query:
SELECT total
FROM (
SELECT price * quantity AS total
FROM line_items
) AS priced_items
WHERE total > 100;
The outer WHERE can refer to total because it is now a column supplied by the derived table, rather than an alias being introduced by the same SELECT list.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesWhy does ORDER BY recognize a column alias?
ORDER BY is applied after SELECT in SQL Server’s documented logical processing order, so the output name is available to it. For example:
SELECT price * quantity AS total
FROM line_items
ORDER BY total;
MySQL documents the same pattern with full_name as an alias for a concatenated expression, and permits output column names in ORDER BY. PostgreSQL 18 likewise allows ORDER BY to refer to an output column name or position. MySQL 8.4 Reference Manual: SELECT Statement; PostgreSQL 18 Documentation: SELECT.
The fact that ORDER BY can use an alias does not mean every clause can. Alias visibility is clause-specific, and database dialects may define additional allowances.
Rank #4
Logical order is not the physical execution plan
Clause order is useful for understanding which names are available during binding. It should not be read as a literal account of the work performed by the database engine. Microsoft Learn distinguishes logical processing order from physical execution: the query processor determines the physical execution, and the order may vary. Microsoft Learn: SELECT (Transact-SQL).
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →The distinction matters because a database can transform a query while preserving its result. The binding model explains why a name is accepted or rejected; it does not predict the physical plan or the number of times an expression is evaluated.
Best Value
How alias rules vary by clause and database
These documented behaviors apply to the cited product documentation and versions; they should not be generalized to every SQL engine or every clause.
| Database documentation | WHERE | ORDER BY | GROUP BY / HAVING | Name collision behavior |
|---|---|---|---|---|
| SQL Server, Microsoft Learn page for SQL Server 2016 | A SELECT-defined alias is unavailable to preceding clauses. | A SELECT-defined alias is available to subsequent clauses. | The documented logical order places GROUP BY and HAVING before SELECT. | The cited page describes preceding-versus-subsequent clause visibility; it does not establish a collision rule here. |
| MySQL 8.4 Reference Manual | SELECT aliases are not permitted. | Output names, aliases, and positions are allowed. | Aliases are allowed in GROUP BY and HAVING. | ORDER BY searches SELECT expressions before FROM columns; GROUP BY and HAVING search FROM columns before SELECT expressions. |
| PostgreSQL 18 Documentation | The cited SELECT documentation does not establish SELECT-alias use in WHERE. | An output name or position is allowed, as is an input expression. | GROUP BY follows a different name-resolution rule from ORDER BY. | A simple matching name resolves to the output name in ORDER BY, but to the input column in GROUP BY. |
WHERE and HAVING are not interchangeable
WHERE filters rows before grouping; HAVING filters groups. MySQL 8.4 permits SELECT aliases in HAVING, unlike WHERE. That is a dialect-specific allowance, not evidence that a SELECT alias is available to all filtering clauses. MySQL 8.4 Reference Manual: SELECT Statement.
Watch for ambiguous names
If an output alias and an input column share a name, a reference may resolve differently depending on the clause and database. PostgreSQL 18 chooses the output name for a simple matching name in ORDER BY, but the input column in GROUP BY. MySQL 8.4 documents that ORDER BY searches SELECT expressions first, while GROUP BY and HAVING search FROM columns first. Choose distinctive aliases and qualify input-column references where appropriate to make intent clear. PostgreSQL 18 Documentation: SELECT; MySQL 8.4 Reference Manual: SELECT Statement.
Free tools Windows power users keep installed
One-click scans. No signup required.
MySQL also permits positions in ORDER BY and GROUP BY, but its manual notes that positional references are deprecated because that syntax was removed from the SQL standard. Named expressions are generally clearer when the query changes.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




