title: invalid identifier error in oracle due to column alias
body: <p>I have a query as follows</p>
  
  <pre><code>select t.col1,
   t.col2,
   (select count(col1)
    from tab 
    where col1 = t.col1
          and col2 = t.col2
     ) as col3 
  from tab t
  where col3 &gt; 1
  </code></pre>
  
  <p>The query gives an 'col3 invalid identifier' error.</p>
  
  <p>I have tried different variations defining the alias which I have given below and the error I get when I use them</p>
  
  <ol>
  <li><pre><code>select t.col1,
         t.col2,
         (select count(col1)
          from tab 
          where col1 = t.col1
            and col2 = t.col2
         ) as "col3" 
  from tab t
  where col3 &gt; 1
  </code></pre></li>
  </ol>
  
  <p>Error: col3 invalid identifier</p>
  
  <ol>
  <li><pre><code>select t.col1,
         t.col2,
         (select count(col1)
          from tab 
          where col1 = t.col1
            and col2 = t.col2
          ) as 'col3' 
  from tab t
  where [col3] &gt; 1
  </code></pre></li>
  </ol>
  
  <p>Error: Missing expression after where</p>
  
  <ol>
  <li><pre><code>select t.col1,
         t.col2,
         (select count(col1)
          from tab 
          where col1 = t.col1
            and col2 = t.col2
         ) "col3" 
  from tab t
  where [col3] &gt; 1
  </code></pre></li>
  </ol>
  
  <p>Error: Missing expression after where</p>
  
  <p>Please explain me what the errors are about</p>
  
  <p>P.S. I don't know why I am unable to mark the query examples as code here. I apologize for the poor readability of those queries</p>