Re: Resettin Running Total

From: Roji. P. Thomas (lazydragon_at_nowhere.com)
Date: 08/16/04


Date: Tue, 17 Aug 2004 00:20:32 +0530


(woth Courtesy to Louis)

SELECT col1, col2, sum(col3) as Total
GROUP BY col1, col2

is considered okay, so why u always recommend a tool instead of

Select col1, col2, concatenate(col2, varcharcolumn) as UDAggregate
GROUP BY col1, col2

-- 
Roji. P. Thomas
Net Asset Management
https://www.netassetmanagement.com
"G.C.Mandrake" <steve.nospam.@rac4sql.net> wrote in message
news:eoAg$47gEHA.536@TK2MSFTNGP11.phx.gbl...
> With Yukon on the horizon it's important that users,especially
> those just coming to the sql world, have as clear an understanding
> of concepts as possible.For example,
>
> "Joe Celko" <jcelko212@earthlink.net> wrote in message
> news:O903SghgEHA.3988@tk2msftngp13.phx.gbl...
> > .
> > 3) Running totals are a report.  We do reports in the front end with
> > report writers and format data in the front end.  You do not do this in
> > the database.  This the whole idea of tiered architectures.
>
> Yet in the thread:
> From: Joe Celko
> Subject: Re: Alternative for TOP
> Newsgroups: microsoft.public.sqlserver.programming
> Date: 2004-08-04 11:09:22 PST
> http://tinyurl.com/4q7hz
>
> You write:
> 'The best answer given uses a subquery to establish a subset based on a
> count.'
>
> SELECT DISTINCT salary
>    FROM Personnel AS P1
>   WHERE @n >= (SELECT COUNT(*) - 1  -- control parameter
>                FROM Personnel AS P2
>               WHERE P1.salary < P2.salary)
>
> Now the same correlated subquery idea can, of course, when used
> with *SUM*, give a running total.You are simply telling users that
> the *same* construct is appropriate or non appropriate based
> on its intent, ie. display(Select) vs. filter(Where).
> Is this the message you really want to give?
>
>


Relevant Pages

  • Re: sum column
    ... MS Access MVP ... > In my report I have two columns: Col1, Col2 and in the ...
    (microsoft.public.access.reports)
  • Re: Inserting multiple records into two tables...with a twist
    ... I assume that you have an IDENTITY column, ... reason would typically be a high rate of concurrent insertions.) ... INSERT tblB(id, col1, col2, ... ...
    (comp.databases.ms-sqlserver)
  • Dynamic PreparedStatements with Variable In Parameters
    ... AND col2=? ... AND col3=? ... I have to start coding tomorrow so I'm eager ...
    (comp.lang.java.programmer)
  • Re: Required property of Primary Key fields
    ... col1 INTEGER NOT NULL, ... PRIMARY KEY (col1, col2) ... it's a bit pointless because the INSERT will fail with a "primary key ...
    (microsoft.public.access.tablesdbdesign)
  • RE: tough query (for me)
    ... query, I had to write VB code which used one query which obtained all of the ... would obtain data from both Col1 and Col2 into a recordset. ... Col1 and Col2 data to an array. ...
    (microsoft.public.access.queries)