Matarishvan
Matarishvan

Reputation: 2432

Calulate the sum of total present in a row - Dynamic HTML Table

I have a dynamic HTML table. Which has A,B,C,D,E... Columns. My data as well as columns are dynamic. I haved added a new column total at the end. Where i need to add the values present in each column and put it in the last

-----  -----  -----  -----  -----       -------
  A      B      C      D      E   ....   Total
-----  -----  -----  -----  -----       -------
  -      -      12     1      -           13
  4      -      -      -      -           4
  -      3      2      5      -           10

I have been referring to this Fiddle. But could not change the code into my requirements. How do i calculate total for dynamic columns

Upvotes: 0

Views: 203

Answers (1)

CurseStacker
CurseStacker

Reputation: 1079

Don't forget to add the same WHERE clause criteria from your first query to your Summary query

SELECT A, B, C, D, E FROM [table]
UNION
SELECT SUM(A) AS A, SUM(B) AS B, SUM(C) AS C, SUM(D) AS D, SUM(E) AS E
FROM [table]

Upvotes: 1

Related Questions