title: Use the same select in postgres several times
body: <p>I have several updates, deletes and inserts in one transaction.
  Want to make postgres function.
  In all queries I have the same big part of conditions like:</p>
  
  <pre><code>WHERE smth IN (SELECT ... IN (SELECT ... ) AND ... NOT IN (SELECT ...) ...)
  </code></pre>
  
  <p>In fundamental of DRY, I don't want to copy-paste the same block of SQL query to each query. What the best way to separate this big SELECT to use it as varible or something likely in my function?  </p>