title: Google Spreadsheet Queries : How to get the first record of each group?
body: <p>Sample database:[Stored as Google spreadsheet]</p>
  
  <blockquote>
    <ul>
    <li>Timestamp=======|=Contact No=|=Bill=======|</li>
    <li>===============|===========|==-========|</li>
    <li>11/7/2014 2:46:29 |    9332261982 | 13.0305472 |</li>
    <li>15/6/2014 2:46:29 |    9332261982 | 14.0305472 | </li>
    <li>22/5/2014 2:46:29 |    9332261982 | 16.0305472 | </li>
    <li>11/4/2014 2:46:29 |    9332261982 | 20.0305472 | </li>
    <li>15/7/2014 2:46:29 |    9916901970 | 13.0305472 | </li>
    <li>1/6/2014 2:46:29  |    9916901970 | 14.0305472 | </li>
    <li>12/5/2014 2:46:29 |    9916901970 | 16.0305472 | </li>
    <li>20/4/2014 2:46:29 |    9916901970 | 20.0305472 |</li>
    </ul>
  </blockquote>
  
  <p>I need: </p>
  
  <blockquote>
    <ul>
    <li>Timestamp=======|=Contact No=|=Bill=======|</li>
    <li>===============|===========|===========|</li>
    <li>11/7/2014 2:46:29 |    9332261982 | 13.0305472 |</li>
    <li>15/7/2014 2:46:29 |    9916901970 | 13.0305472 |</li>
    </ul>
  </blockquote>
  
  <p>So I have 3 columns Time stamp(Column - A), Contact Number(Column - B) and Bill amount(Column - C) in a Google Spreadsheet.
  I need a big query(or a query that I can use with Google Spreadsheet) that can fetch me the most recent bill amount by time stamp for each contact if I pass that contact in the query(as a where clause - as in where B contains XXX or B contains YYY).</p>
  
  <p>So far by checking other Stack overflow links and Google search I have come up with something like this:</p>
  
  <pre><code>select * where B contains 9332261982 order by A DESC LIMIT 1 OFFSET 0
  </code></pre>
  
  <p>or</p>
  
  <pre><code>select A,B,C where B contains 9332261982 or B contains 9916901970 order by A DESC
  </code></pre>
  
  <p>So how to marge this and get the Query I want?</p>