【发布时间】:2020-04-15 08:25:26
【问题描述】:
我想得到一个值 group_by 'recivedID' 但不能正常工作。查找值只有一个第一个值显示在表单上如何显示所有添加所有值并显示。
表'fuel_transaction'
recivedID hsdltrs
1 500
1 600
1 300
2 100
2 600
结果显示在表单上 // 不需要
recivedID ->1
hsdltrs ->500 //worng result
我需要结果
//hsdltrs ->500+600+300=1400
recivedID ->1
hsdltrs ->1400
<?php
//$this->db->Select SUM(ABS(hsdltrs)) as Data ; //error please check its sir
$this->db->where('issuedate >=',$date1);
$this->db->where('issuedate <=',$date2);
$this->db->where('recivedID',$a);
$this->db->group_by('recivedID');
$queryb = $this->db->get('fuel_transaction');
if ($queryb->num_rows() > 0)
{
foreach ($queryb->result() as $rowc)
{
$tdate = $rowc->issuedate;
$hsdltrs = $rowc->hsdltrs;
$hsd += $rowc->hsdltrs;
?>
【问题讨论】: