简体   繁体   中英

Pivot tables - column alias not recognized in select statement

I am trying to produce a pivoted table. 我这里有查询和数据的图片。

I have aliased column names, since the columns are being aggregated.

Why isn't my alias usable?

这是错误消息的图片。

Since you are aggregating the data in the Enrollment column via sum(Enrollment) that column is no longer available for the final select list. Remove it from the final select list and the query should work without any issues.

The thing to remember when using a PIVOT is columns you use inside of the statement are being replaced because you are converting the values into new columns. In the case of your query, both the Enrollment and ProgramType are not available in the final select.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM