title: Most efficient way to subset a query to a list of dates (across two columns) in PostgreSQL?
body: <p>I am querying a table in a PG database which contains a <code>period</code> (<code>character varying(255)</code>) and a <code>value</code> (<code>integer</code>), which looks something like:</p>
  
  <pre><code>|period|value|
  |Months|3    |
  |Months|6    |
  |Weeks |1    |
  |Years |5    |
  </code></pre>
  
  <p>After a few joins, I'm looking to subset my result set to only include a subset of these period / value combinations, for example I may only want 3 Months, 6 Months and 5 Years (so not 1 Weeks).</p>
  
  <p>I'd usually reach to a <code>WHERE IN(..)</code> but don't think I can do this across two columns. Instead I've tried to make a composite column by:</p>
  
  <p><code>CURRENT_DATE + CAST(CONCAT(tbl.value, tbl.period) AS INTERVAL)</code></p>
  
  <p>Producing a column of <code>timestamp</code>s which I can then subset with an <code>IN('2019-05-18', '2019-08-18', '2024-02-18')</code>.</p>
  
  <p>This works but isn't particularly pretty or efficient. Is there a better way?</p>
  
  <p>I'm free to change my query (so I can subset by dates as I currently am, or by <code>3</code> and <code>Months</code>) but importantly I do not know ahead of time whether 2 Years will be stored as 24 Months (nor do I have control of the table).</p>
  
  <p>Thanks!</p>