Hello guys I'm creating a daily report. I'm a beginner on my MySQL.
I want to generate this kind of data.
I have a table in my phpmyadmin with this structure
<table>
<tr>
<th>ID</th>
<th>Item_desc<th>
<th>Total_price<th>
<th>Quantity</th>
<th>Date</th>
<th>Branch</th>
</tr>
<tr>
<td>1</td>
<td>Bottle</td>
<td>100 </td>
<td>10 </td>
<td>June 26,2016 </td>
<td>Rizal</td>
</tr>
<tr>
<td>2</td>
<td>Bottle</td>
<td>120 </td>
<td>12 </td>
<td>June 26,2016 </td>
<td>Rizal</td>
</tr>
<tr>
<td>3</td>
<td>Bottle</td>
<td>100 </td>
<td>10 </td>
<td>June 26,2016 </td>
<td>Rizal</td>
</tr>
</table>
But I'm getting only 1 record. I want to get all of that records with the sum of total_price and quantity. This is my current query. Thank you.
$query= $this->db->select('*,SUM(total_price),SUM(quantity)')->from('sales')->where('branch',$_SESSION['branch'])->where('date',$from)->get();
Aucun commentaire:
Enregistrer un commentaire