title: Oracle nested multiple subqueries
body: <p>I am looking for a reliable algorithmic way to nest queries in Oracle without having to parse and rebuild SQL statements. In DB2, MYSQL, and SQLITE I can simply nest from the largest columns set in the inner subquery to the smallest column set in the very outer query like this:</p>
  
  <pre><code>  SELECT A, B FROM (
         SELECT A, B, C FROM (
              SELECT A, B, C, D FROM (
                   SELECT * FROM myTable
                   )
              )
        )
   )
  </code></pre>
  
  <p>This does not work for Oracle, I had to use the WITH clause but that allows me one level of nesting like </p>
  
  <pre><code> WITH Q1 as (
        SELECT * FROM myTable 
              ) 
              SELECT A, B FROM Q1
  </code></pre>
  
  <p>is there an algorithmic way to nest select statements in Oracle like DB2 or MySQL above </p>
  
  <p>You can always assume it is a single table. The queries are generated automatically                  </p>
  
  <p>Found the root cause:</p>
  
  <p>My code assumes an "AS alias" is needed and appends it to the subquery as in "Select A, B from (select A, B, C from myTable) <strong>AS Q1</strong>"      --- Oracle does not like that and gives an error  "missing right parenthesis" </p>