title: SQL: WITH clause with parameters?
body: <p>In Oracle SQL Developer, I am using a WITH clause, in this (simplified) way:</p>
  
  <pre><code>WITH
  foos AS
      SELECT *
      FROM my_table
      WHERE field = 'foo'
  bars AS
      SELECT *
      FROM my_table
      WHERE field = 'bar'
  SELECT *
  FROM foo
  INNER JOIN bar
  ON foo.id = bar.id
  </code></pre>
  
  <p>I would like to be able to factor out the 'foo' and 'bar' strings, so that I can have something like:</p>
  
  <pre><code>WITH
  subq(my_arg) AS
      SELECT *
      FROM my_table
      WHERE field = my_arg
  SELECT *
  FROM subq('foo')
  INNER JOIN subq('bar')
  ON subq('foo').id = subq('foo').id
  </code></pre>
  
  <p>Because, <code>foos</code> and <code>bars</code> are actually much bigger than this, and there are nut just two of them, so it is getting a bit hard to maintain.</p>
  
  <p>I know this may be not possible with a WITH clause, but what would be the best solution to avoid writing this subquery multiple times? This may be actually quite simple, but I am quite new to SQL...</p>
  
  <p>Thanks for your help.</p>