Jump to content


I need to sum rows and columns like in a spreadsheet

sum rows column spreadsheet

  • Please log in to reply
3 replies to this topic

#1 rhalsey

rhalsey

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 08 November 2011 - 11:39 AM

Hello!!

This is GREAT stuff!!  I had almost given up on codeigniter when I found your script!

I am using version 1.1.3.

I need to sum rows and columns.

Can you tell me how to do that?

___Item_____J___F___M_  Tot  
Good Days | 10  |  20  |  30  |  60  |
Bad Days   |  20 |  30  |  40  |  90  |
Total  Days |  30  |  50  |  70  | 150 |

Any help you could give would be great!!

Thank you again for your GREAT work!!!!!!!

Rich Halsey
www.marricorp.com

#2 rhalsey

rhalsey

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 10 November 2011 - 12:22 AM

Can anyone help with this or at least point me in the right direction?

Thanks in advance!!

#3 goFrendiAsgard

goFrendiAsgard

    Advanced Member

  • Members
  • PipPipPip
  • 137 posts

Posted 11 November 2011 - 02:06 AM

Hi there, I think it is not about groceryCRUD, but it is about SQL.
Assume that you have 2 rows in your table_day(Item, J, F, M).

To make total row, you might need to make such a view (let's assume it as view_a) :

SELECT item, J, F, M, (J+F+M) as total FROM table_day

For total column, it might be more complicated.
You should make another view (let's assume it as view_b ):
SELECT 'total', sum(J) as J, sum(F) as F, sum(total) as total FROM view_a;


And you should make the third view that combine view_a and view_b (I forgot the detail, but you might googling for that).

I hope it can help.

Ah, there is some side effect of this, you should not edit, add, or delete from a view, that's mean that the grid can only be viewed (or you will need some complicated callback).

goFrendiAsgard

No-CMS homepage : http://www.getnocms.com
No-CMS forum : http://www.getnocms.com/forum
No-CMS Github page : https://github.com/g...diAsgard/No-CMS

 

Please don't mix up No-CMS and groceryCRUD issues.
(eg: user authentication etc is No-CMS specific issue and has nothing to do with groceryCRUD)

 


#4 rhalsey

rhalsey

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 11 November 2011 - 10:23 AM

Thank you!  It gives me a place to start!





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users