title: how to write sql query to compare today's price with yesterday's
body: <p>Given a price table, write a SQL query to find the  Ids with higher price compared to its previous (yesterday's) dates</p>
  
  <p>table price</p>
  
  <pre><code>|    Id   |    Date    |  price |
  |       1 | 2015-01-01 |     20 |
  |       2 | 2015-01-02 |     30 |
  |       3 | 2015-01-03 |     40 |
  </code></pre>
  
  <p>Question : I tried to use <code>to_days</code> to express the concept of "yesterday" but my sql developer cannot recognize this function  </p>
  
  <pre><code>select p1.id
  from  price p1, price p2
  WHERE p1.price &gt; p2.price
  AND   TO_days(p1.date)-TO_days(p2.date)=1;
  </code></pre>
  
  <p>I also tried to use <code>subdate()</code> function to compare the price, but again I got  invalid identifier error, what is wrong?</p>
  
  <pre><code>select p1.id 
  from  price p1, price p2
  WHERE p1.price &gt; p2.price
  AND   subdate(p1.date, 1)= p1.date;
  </code></pre>