I'm trying to perform a SQL query through a linked SSAS server. The initial query works fine:
SELECT "Ugly OLAP name" as "Value"
FROM OpenQuery( OLAP, 'OLAP Query')
But if I try to add:
WHERE "Value" > 0
I get an error
Invalid column name 'Value'
Any ideas what I might be doing wrong?
So the problem was that the order in which elements of the query are processed are different that the order they are written. According to this source:
http://blogs.x2line.com/al/archive/2007/06/30/3187.aspx
The order of evaluation in MSSQL is:
- FROM
- ON
- JOIN
- WHERE
- GROUP BY
- HAVING
- SELECT
- ORDER BY
So the alias wasn't processed until after the WHERE and HAVING clauses.