[freetds] Query - Sum(data) by Date?

Owen, Robert robert.owen at nortonrose.com
Thu Nov 10 11:33:27 EST 2005


Craig,

If you wish to sum grouping by whole days you need to first create a
temporary pivot table containing containing either whole dates (i.e.
with zero time) or alternatively integers from which you can create
whole dates (using dateadd etc.).

Then join to your table but group by the pivot table row.

Try googling for Pivot and SQL ;)

Rob.


-----Original Message-----
From: freetds-bounces at lists.ibiblio.org
[mailto:freetds-bounces at lists.ibiblio.org] On Behalf Of Shaun Craig
Sent: 10 November 2005 15:48
To: FreeTDS Development Group
Subject: [freetds] Query - Sum(data) by Date?


How do i go about this, i have a single table 'Flow' which holds values 
for a particular object for a date, ie

'Object'      'Level'      'Date/Time'

Object1      2.0            Nov 09 2005 10:02AM
Object1      3.3            Nov 09 2005 11:32AM
Object1      1.2            Nov 09 2005 13:12PM
etc........
Object1      3.4            Nov 10 2005 04:12AM
Object1      0.1            Nov 10 2005 11:23PM
etc...

I want a query which will sum(level) for each date, so result will look 
like the following

'Object'      'Total Level for Date'      'Date'

Object1      6.5                                    Nov 09 2005
Object1      3.5                                    Nov 10 2005

Any ideas, had a look on the web but you need to sign up to stuff to see

solutions, not an option.

Thanks,

Shaun.
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

________________________________________________________
CONFIDENTIALITY NOTICE

The contents of this e-mail are confidential to the ordinary user of
the e-mail address to which it was addressed and may also be
privileged.  If you are not the addressee of this e-mail you may not
copy, forward, disclose or otherwise use it or any part of it in any
form whatsoever.  If you have received this e-mail in error please
e-mail the sender by replying to this message.

A list of the partners of Norton Rose, Solicitors, can be inspected at
www.nortonrose.com 

Please refer to www.nortonrose.com/regulation for the firm's regulatory position.

Regulated by the Law Society.
________________________________________________________



More information about the FreeTDS mailing list