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 |
tkotey
Yak Posting Veteran
75 Posts |
Posted - 2013-02-23 : 08:31:18
|
HelloHow do I sum and get average of rows from this statement--SELECT DateDiff(dd,convert(datetime,invRecDate,103),convert(datetime,invToAdminPrepDT,103))-DateDiff(ww,convert(datetime,invRecDate,103),convert(datetime,invToAdminPrepDT,103))*2 AS Days FROM reportViewHQ WHERE invWorkshop = 'Fleet'--Thanks for your help |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-02-23 : 09:36:35
|
[code]SELECT SUM(Days) AS SumofDays, AVG(1.0*Days) AS AvgofDaysFROM( SELECT DateDiff(dd,convert(datetime,invRecDate,103), convert(datetime,invToAdminPrepDT,103))-DateDiff(ww,convert(datetime,invRecDate,103), convert(datetime,invToAdminPrepDT,103))*2 AS Days FROM reportViewHQ WHERE invWorkshop = 'Fleet' ) s[/code] |
|
|
tkotey
Yak Posting Veteran
75 Posts |
Posted - 2013-02-23 : 10:04:56
|
Thanks Jams K for help. |
|
|
|
|
|
|
|