On Wed, 29 Jul 2009, P Kishor wrote:

For my part, I don't know how to do a running total in a result set
unless I have some kind of a counter that keeps track of the "row
before the current row"

This is also the only way I know of.

Chris


On Wed, Jul 29, 2009 at 8:50 AM, Rich Shepard<rshep...@appl-ecosys.com> wrote:
On Wed, 29 Jul 2009, Adler, Eliedaat wrote:

SQL/sqlite challenge  for all:

  No challenge for anyone who knows SQL.

I need a running sum of size that works regardless of what order the objects 
are in.
User Function/Aggregates welcome!

  _All_ implementations of SQL include a suite of aggregate functions, and
SUM() is among those. Take a look at the SQLite Web site, Mike Owens's book,
Rick van der Lans's book, or any introduction to SQL.

  You will write, "SELECT filename, date, owner, size, SUM(size) AS total
                       FROM mytable;"



Well, not really. The above totals across the entire result set. The
OP wants a running total, kinda like in a spreadsheet.

Since the question is phrased as a "challenge," I wonder if the OP has
the answer already, and merely wants to test the SQL sages on the
list. Otherwise, a better spirit would be to simply ask the question
as a question, and not as a challenge.

For my part, I don't know how to do a running total in a result set
unless I have some kind of a counter that keeps track of the "row
before the current row"





--
Puneet Kishor
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to