1

i have a group_concat in my query and due to this i cannot have the actual some of the concated values because of the separation is limited between the values, so i need to get the total sum of the concated values instead of the values it self...

my query

. "GROUP_CONCAT(if (sma_sale_items.item_tax >0,round(sma_sale_items.net_unit_price * " . $this->db->dbprefix('sale_items') . ".quantity,2),'\n') SEPARATOR '\n') as unitp,"

which will result in :

1
1
1
1
1

what i need is:

5

any ideas please ?!??!

PS: am using phpexcel to echo the values so if there is an idea from there it would also be great

$this->excel->getActiveSheet()->SetCellValue('F' . $row, $data_row->unitp);
  • Why can't you use a plain old SUM() instead of GROUP_CONCAT()? – Sergey Vidusov Feb 19 '16 at 03:54
  • Check this - http://stackoverflow.com/questions/2228307/how-to-use-sum-within-a-group-concat http://stackoverflow.com/questions/931594/sql-group-concat-sum-avg http://stackoverflow.com/questions/9308867/mysql-group-concat-with-sums-also-inside – Rahul Feb 19 '16 at 03:54
  • To a rough approximation, there is no problem in SQL for which GROUP_CONCAT is the answer. – Strawberry Feb 19 '16 at 08:21

0 Answers0