Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 23rd, 2007, 04:00 PM
Registered User
 
Join Date: Dec 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Combining the average of multiple rows into one

Hello

I'm new to sql server and I'm having a slight problem!

ID FeederTotal Hour Minute
20 400 5 1
160 350 5 1
300 40010 5 1
40 200 20 12
180 210 20 12
300 180 20 12

This is an extract, the data is 24 hour data, many days of them mixed. I want the result to be:

NewID FeederTotal Hour Minute
20 383.33 5 1
100 196.67 20 12

The new FeederTotal is the average of all the totals.

Is there a short way to do this?

Thanks
Franco






 
Old December 23rd, 2007, 08:08 PM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

Ummm... just take the average of the Feeder total by Hour and Minute in a GROUP BY.

--Jeff Moden
 
Old December 24th, 2007, 03:45 AM
Registered User
 
Join Date: Dec 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OO cool thanx man! For some reason I thought group by and order by is the same so didn't think of that.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining Multiple rows LateBinding SQL Server 2000 0 February 23rd, 2007 05:23 AM
Highlighting multiple rows nzhang ASP.NET 2.0 Basics 1 June 21st, 2006 11:12 PM
Copying Multiple Rows raj_phoenix Excel VBA 3 May 6th, 2005 03:58 AM
print multiple times..multiple rows... abhit_kumar JSP Basics 3 January 18th, 2005 07:11 PM
Updating multiple Rows from multiple fields in ASP vdm_nana SQL Server ASP 0 April 1st, 2004 04:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.