title: QUERY using cell contents as SQL variables
body: <p>Here is what the spreadsheet I'm working with looks like:</p>
  
  <h3>Summary table</h3>
  
  <p>(top of sheet)</p>
  
  <p><img src="https://i.stack.imgur.com/pZsljm.png" alt="screenshot"></p>
  
  <h3>Source data</h3>
  
  <p>(same sheet, below output)</p>
  
  <p><img src="https://i.stack.imgur.com/whRqom.png" alt="screenshot"></p>
  
  <p>I'm using the <a href="https://support.google.com/docs/answer/3093343" rel="nofollow noreferrer">QUERY</a> function to populate the appropriate feeds in the summary table with the data starting at A24 needs to be placed into.</p>
  
  <p>Here is the formula I'm using in cell C6 (similar formulas are used throughout the summary table):</p>
  
  <pre><code>=QUERY($A$24:$D$57, "Select D Where B='ENQ' and A='2/27/14 - Thu'")
  </code></pre>
  
  <p>This gets the right information, but the formula needs to be edited to be unique in each cell it's used in. The problem being unable to quickly populate the cells with <code>A='2/27/14 - Thu'</code> being too specific.</p>
  
  <p>I was trying to set it up so that:</p>
  
  <ul>
  <li>date in A would compare with dates found on headers in ROW 2 before accepting data</li>
  <li>room type in B would compare with value from A in each row of the summary table</li>
  </ul>
  
  <p>How can the QUERY function be written to refer to these values as variables, instead of using the literal strings in my original function?</p>