title: aliased union in SQLAlchemy
body: <p>In sqlalchemy I am trying to union tables and then make alias with <code>WHERE</code> and <code>ORDER_BY</code></p>
  
  <p>something like</p>
  
  <pre><code>SELECT *
  FROM (
    SELECT [TABLE_ONE].[SOME_ID] AS [SOME_ID]
    FROM [TABLE_ONE] 
    UNION 
    SELECT [TABLE_TWO].[SOME_ID] AS [SOME_ID]
    FROM [TABLE_TWO]
  ) AS anon_1
  WHERE ...
  </code></pre>
  
  <p>SQLAlchemy:</p>
  
  <pre><code>select_q = select([TABLE_ONE.c.SOME_ID], TABLE_ONE)
  select_w = select([TABLE_TWO.c.SOME_ID], TABLE_TWO)
  union_qw = union(select_q,select_w) 
  union_qw_aliased = aliased(union_qw)
  s = select('*',union_qw_aliased)
  </code></pre>
  
  <p>but SQLAlchemy produces SQL code:</p>
  
  <pre><code>SELECT anon_1.[SOME_ID]
  FROM (SELECT [TABLE_ONE].[SOME_ID] AS [SOME_ID]
  FROM [TABLE_ONE] UNION SELECT [TABLE_TWO].[SOME_ID] AS [SOME_ID]
  FROM [TABLE_TWO]) AS anon_1
  WHERE SELECT [TABLE_ONE].[SOME_ID]
  FROM [TABLE_ONE] UNION SELECT [TABLE_TWO].[SOME_ID]
  FROM [TABLE_TWO]
  </code></pre>
  
  <p>Any help is appreciated</p>