Get first and last record number in every date exists in table
<p>I am trying to show invoices for every single day, so for that purpose I used group by on created date and sum on subtotal. This is how I done it :</p>

<pre><code>  SELECT 
         `main_table`.*, 
         SUM(subtotal) AS `total_sales` 
  FROM 
        `sales_invoice` AS `main_table` 
  GROUP BY 
        DATE_FORMAT(created_at, "%m-%y")
</code></pre>

<p>Its working, but I also want to get the Invoice # from and Invoice # to for every date. Is it possible to do it with single query ?</p>

<p><strong>EDIT :</strong> </p>

<p><strong>Table Structure :</strong> </p>

<pre><code>------------------------------------------------
| id | inoice_no | created_at           | subtotal

| 1  | 34        | 2015-03-17 05:55:27  | 5 
| 2  | 35        | 2015-03-17 12:35:00  | 7
| 3  | 36        | 2015-03-20 01:40:00  | 3
| 4  | 37        | 2015-03-20 07:05:13  | 6 
| 5  | 38        | 2015-03-20 10:25:23  | 1
| 6  | 39        | 2015-03-24 12:00:00  | 6
------------------------------------------------
</code></pre>

<p><strong>Output</strong></p>

<pre><code>---------------------------------------------------------------
| id | inoice_no | created_at           | subtotal | total_sales

| 2  | 35        | 2015-03-17 12:35:00  | 7        | 12
| 5  | 38        | 2015-03-20 10:25:23  | 1        | 10
| 6  | 39        | 2015-03-24 12:00:00  | 6        | 6
-----------------------------------------------------------------
</code></pre>

<p><strong>What I Expect</strong></p>

<pre><code>---------------------------------------------------------------
| id | inoice_no | created_at           | subtotal | total_sales | in_from | in_to

| 2  | 35        | 2015-03-17 12:35:00  | 7        | 12          | 34      | 35
| 5  | 38        | 2015-03-20 10:25:23  | 1        | 10          | 36      | 38
| 6  | 39        | 2015-03-24 12:00:00  | 6        | 6           | 39      | 39
-----------------------------------------------------------------
</code></pre>