Skip to main content

Aliases and selecting from a select

Rarely do you need select from a select statement.

Occasionally this pops up with complex PIVOTs and UNPIVOTs.

The tip when doing this is (in MSSQL) is the "table" select statement needs to be aliased.

For example, the following statement will not work:

SELECT * FROM ( SELECT * FROM blah ) 

However, the following statement will work:

SELECT * FROM ( SELECT * FROM blah ) x



Comments

Popular posts from this blog