0

If type and serial no is same I want to add the amount of both row and display in single row this the image of display the rows:
this the image of display the rows

SELECT SUM(amount),`type`,`account_id` FROM `general_ledger` GROUP BY `type`

I TIRED THIS QUERY it worked but I can't return all column of the table, if I did it showing error of

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\wamp64\www\Vesta\account\report\general_ledger.php on line 104

This Table Structure Table Structure :
Table Structure

I want to SUM of amount by GROUP BY type and return all the rows by condition WHERE account_id = '$account_id' I tried many way I figure it out still I didn't find the solution and reason for error.

Dharman
  • 26,923
  • 21
  • 73
  • 125
sajeevan
  • 23
  • 1
  • 6

1 Answers1

1

type and serial .. add the amount ... and display in single row:

SELECT SUM(amount), type, serial FROM general_ledger GROUP BY type, serial

for each column (NOT using an aggregate function) repeat those columns in the group by clause

Paul Maxwell
  • 28,051
  • 3
  • 30
  • 50