FROM THE BOOK Previously, you have used the count operator to count records. Similarly, you can use the sum operator to add (sum) the values of a specific field from a group of records. As in the case of count, the result of a sum is retrieved via the store object:
1. 2. 3. >>> sum = db.log.severity.sum() >>> print db().select(sum).first()[sum] 6 Expression can be combined to form more complex expressions. For example here we are computing the sum of the length of all the servery strings in the logs, increased of one: 1. 2. >>> sum = (db.log.severity.len()+1).sum() >>> print db().select(sum).first()[sum] 2011/10/20 Anthony <[email protected]> > Wait, do you mean that you did the sum as part of the select? What exactly > did you return to the view (the whole Rows object), and how do you want to > display the results? In general, you would access the sum "field" like > rows[row_number]['SUM(t_table.f_field)']. Note, you can also assign the > sum to a variable prior to the select and then use the variable name to > access the sum from the Rows object -- see > http://web2py.com/book/default/chapter/06#belongs (sum is discussed right > after belongs). > > > On Thursday, October 20, 2011 1:27:02 AM UTC-4, andrej burja wrote: > >> in controler i do join and sum >> the result si rows object >> in response._vars the sum is displayed in >> SUM(t_table.f_field) >> >> what is the syntax to display that in view? >> >> andrej >> > -- http://martin.tecnodoc.com.ar

