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.
| Author |
Topic |
|
jpiscit1
Posting Yak Master
130 Posts |
Posted - 2003-04-03 : 23:03:22
|
| Hi,Im trying to find an average for a given set of records.I have a table that accumulates production at 1 min intervals. Each record stores the product name and campaign number. As a result I can run a query as such and get a list of the losses for each run where the campaign number is distinctively listed in he table.DECLARE @Product char (10)SET @Product = 'ProductName'SELECT Distinct campaign_number,SUM (couch_speed/3 *(DateDiff (ss,(CONVERT(datetime, Loop_pump_start)),(CONVERT(datetime, Turn_up_button_pressed)))/60)-113.72)FROM tbl_3PMStartTimesWHERE tbl_3PMStartTimes.product = @ProductGROUP BY campaign_numberI end up with a result such as:Campaign Losses301498 213.013329301513 314.113322301534 339.880000301561 188.279992I'm trying to get the average losses in this result. In this case it would be 263.82. Any suggestions on how I can do this? Any help is appreciated.John |
|
|
samsekar
Constraint Violating Yak Guru
437 Posts |
Posted - 2003-04-04 : 00:23:25
|
| HTH..SELECT AVG(A.losses) as AVG_Losses from (SELECT Distinct campaign_number, SUM (couch_speed/3 *(DateDiff (ss,(CONVERT(datetime, Loop_pump_start)),(CONVERT(datetime, Turn_up_button_pressed)))/60)-113.72) as lossesFROM tbl_3PMStartTimes WHERE tbl_3PMStartTimes.product = @Product GROUP BY campaign_number) as ASekar~~~~Success is not a destination that you ever reach. Success is the quality of your journey. |
 |
|
|
|
|
|