Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Weekly aggregation

Author  Topic 

Johnyalm
Starting Member

49 Posts

Posted - 2005-05-07 : 11:08:49
I would like to aggregate a floatvalue and get the average of 7 days records and only get each weeks value (AVG steps)

My table looks like this.

TABLE.date
TABLE.floatvalue (steps taken each day)
TABLE.??

Now there is 7 records for each week, but I would like to get ONE record for the week with "steps" sum and AVG of steps.

Is there a good way to have SQL server to aggregate, sum and get AVG in an easy way?

www.mirrorgate.com

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2005-05-07 : 11:22:49
Is there some reason you can't use the SUM and AVG aggregates? And filter the search to the last seven days by using the WHERE clause.

What exactly is a "steps" sum?

HTH

=================================================================
Some mistakes are too much fun to only make once.
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2005-05-07 : 11:45:45
Why are you using float for this?

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

Johnyalm
Starting Member

49 Posts

Posted - 2005-05-07 : 17:58:19
Why should I not use float?

www.mirrorgate.com
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2005-05-07 : 19:56:43
From Books Online:

quote:

Approximate number data types for use with floating point numeric data. Floating point data is approximate; not all values in the data type range can be precisely represented.



MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

Johnyalm
Starting Member

49 Posts

Posted - 2005-05-08 : 01:18:39
Thanks a lot. Changed it to decimal!

/Johny

www.mirrorgate.com
Go to Top of Page
   

- Advertisement -