title: Help with a SQL Query
body: <p>I am wanting to perform a Threshold query, whereby one would take the Value of a field from Today, and compare it to the value from yesterday, this query would look something like this, but obviously, it is wrong, and I can't find how to do it:</p>
  
  <pre><code>select 
     TableB.Name, 
     TableA.Charge, 
     ( 
       select Charge 
       from TableA 
       where (DateAdded &gt;= '13/10/2009' and DateAdded &lt; '14/10/2009')
     ) 
       from TableA
  
  inner join 
     TableB on TableB.ID = TableA.ID
  
  where 
     TableA.DateAdded &gt;= '10/14/2009'
  
  order by 
     Name asc
  </code></pre>
  
  <p>Just a quick note, I am looking for two <code>CHARGE</code> fields, not the dates. The date manipulation is simply for Today and Yesterday, nothing more.</p>
  
  <p>At the end of this, I want to do a calculation on the two returned charge fields, so if its easier to show that, that would also be great.</p>
  
  <p>Thanks in advance</p>
  
  <p>Kyle</p>
  
  <p>EDIT1:</p>
  
  <p>The data I am looking for is like so:</p>
  
  <p>Yesterday, we input a charge of 500 to MachineA
  Today we input a charge of 300 to MachineA</p>
  
  <p>We run the query, and results I need are as follows:</p>
  
  <pre><code>Name = MachineA
  Charge = 300
  YesterdayCharge = 500
  </code></pre>