<p>I'm trying to perform a SQL query through a linked SSAS server.  The initial query works fine:</p>

<pre><code>SELECT "Ugly OLAP name" as "Value" 
FROM OpenQuery( OLAP, 'OLAP Query')
</code></pre>

<p>But if I try to add:</p>

<pre><code>WHERE "Value" &gt; 0
</code></pre>

<p>I get an error</p>

<blockquote>
  <p>Invalid column name 'Value'</p>
</blockquote>

<p>Any ideas what I might be doing wrong?</p>

<hr>

<p>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:</p>

<p><a href="http://blogs.x2line.com/al/archive/2007/06/30/3187.aspx" rel="noreferrer">http://blogs.x2line.com/al/archive/2007/06/30/3187.aspx</a></p>

<p>The order of evaluation in MSSQL is:</p>

<ol>
<li>FROM</li>
<li>ON</li>
<li>JOIN</li>
<li>WHERE</li>
<li>GROUP BY</li>
<li>HAVING</li>
<li>SELECT</li>
<li>ORDER BY</li>
</ol>

<p>So the alias wasn't processed until after the WHERE and HAVING clauses.</p>

Oh, bummer. I just saw, you select AS FOO. Don't you need a HAVING claus in this case?
```
```
SELECT whatever AS value FROM table HAVING value > 1;
```
```
I still would not use "value". But to be sure, look it up in your docs!