logo       

Re: [sqlite] Subtotal SQL: msg#00817

sqlite-users

Subject: Re: [sqlite] Subtotal SQL


I think this may involve a subquery, probably in the SELECT list itself, which
uses ROWID (or ROWNUMBER... I can't remember which one is a part of the SQL
standard rather than proprietary).

________________________________________
From: sqlite-users-bounces@xxxxxxxxxx [sqlite-users-bounces@xxxxxxxxxx] On
Behalf Of cmartin@xxxxxxx [cmartin@xxxxxxx]
Sent: Wednesday, July 29, 2009 9:08 AM
To: punkish@xxxxxxxxxxx; General Discussion of SQLite Database
Subject: Re: [sqlite] Subtotal SQL

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<rshepard@xxxxxxxxxxxxxxx> 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@xxxxxxxxxx
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>

The information contained in this e-mail is privileged and confidential
information intended only for the use of the individual or entity named. If
you are not the intended recipient, or the employee or agent responsible for
delivering this message to the intended recipient, you are hereby notified that
any disclosure, dissemination, distribution, or copying of this communication
is strictly prohibited. If you have received this e-mail in error, please
immediately notify the sender and delete any copies from your system.
_______________________________________________
sqlite-users mailing list
sqlite-users@xxxxxxxxxx
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Google Custom Search

News | Mail Home | sitemap | FAQ | advertise