Microsoft
Software
Hardware
Network
Question : ms sql calculation in wrong
I have the following sql statement which is giving a wrong result for may and july. april and jun are correct. the only difference is that there are two records for may and jul.
SELECT top 12 CONVERT(VARCHAR, DATEADD(month, DATEDIFF(month, 0, fldStart), 0), 106) as fldDate ,sum([fldClosedOnTime]),su
m([fldassi
gnedclosed
]), SUM([fldClosedOnTime]/[fld
assignedcl
osed]) FROM [KPI].[dbo].[viewSAPrepPro
jectBSC] where DATEADD(month, DATEDIFF(month, 0, fldStart), 0) <= DATEADD(month, DATEDIFF(month, 0, getdate()), 0) group by DATEADD(month, DATEDIFF(month, 0, fldStart), 0) order by DATEADD(month, DATEDIFF(month, 0, fldStart), 0)
fldDate (No column name) (No column name) (No column name)
01 Apr 2010 19 64 0.296875
01 May 2010 19 128 0.296875
01 Jun 2010 24 64 0.375
01 Jul 2010 40 119 0.704261363636364
the raw data is
fldAssignedClosed fldClosedOnTime fldStart
55 31 2010-07-28 00:00:00.000
64 9 2010-07-12 00:00:00.000
64 24 2010-06-23 00:00:00.000
64 15 2010-05-26 00:00:00.000
64 4 2010-05-05 00:00:00.000
64 19 2010-04-28 00:00:00.000
Answer : ms sql calculation in wrong
You mean on the last column? Do you mean
SELECT top 12 CONVERT(VARCHAR, DATEADD(month, DATEDIFF(month, 0, fldStart), 0), 106) as fldDate ,sum([fldClosedOnTime]),su
m([fldassi
gnedclosed
]), 1.0*SUM([fldClosedOnTime])
/Sum([flda
ssignedclo
sed]) FROM [KPI].[dbo].[viewSAPrepPro
jectBSC] where DATEADD(month, DATEDIFF(month, 0, fldStart), 0) <= DATEADD(month, DATEDIFF(month, 0, getdate()), 0) group by DATEADD(month, DATEDIFF(month, 0, fldStart), 0) order by DATEADD(month, DATEDIFF(month, 0, fldStart), 0)
Random Solutions
Jquery NoConflict Issue
How to install Solaris 10 in 2 disks at the same time or 4 disks using zfs, need good documentation on zfs
How to block video and audio streaming in ISA 2006
Will there be a 13" Macbook with an iCore processor anytime soon? Safe to buy C2D?
how do i create a vfp exe which i can call with command line parameters
HP dl360 G6 Raid Driver for Windows 2008 64-bit
Info@... users Not receiving email
asp.net, c#, drop down list error
visual studio 2005 express
plain text feed for exchange rates