0

i want to select data according to date if there are to data with same date like 2 july and again 2 july then echo both data separately in my this query its shows only one date data

function get_this_date_expenses($date)
{
    if (!empty($_POST['ecategory_id'])) {
        $this->db->where('expanses_category_id',
            $_POST['ecategory_id']);
    }
    $this->db->group_by(['MONTH(date)']);
    $this->db->where('DATE(date)', $date);
    $this->db->select('SUM(amount) as total');
    $this->db->select('amount as totals'); --->in this line am select table
    return $this->db->get('expanses')->row();
);
atymic
  • 3,093
  • 1
  • 13
  • 26
anuj horo
  • 21
  • 4
  • I dont get it !!! – hs-dev2 MR Jul 23 '19 at 05:53
  • You're explicitly telling MySQL to return all records with the same dates as one row since you're using `group_by()`. – M. Eriksson Jul 23 '19 at 05:56
  • i want to fetch data accouding to date like there are three data 1 july , 1 july and 2 july i want to fetch booth 1 july data and in my this select query $this->db->select('amount as totals') am only able to fetch only one table from both 1july date – anuj horo Jul 23 '19 at 05:58
  • hope this answer will help you https://stackoverflow.com/questions/11357640/using-sum-without-grouping-the-results – Ezhil Jul 23 '19 at 05:58

0 Answers0