Quantcast
Channel: Quality Center / ALM Practitioners Forum topics
Viewing all articles
Browse latest Browse all 5491

datediff function doesn't work

$
0
0

Hi,

I'm trying to execute this SQL request but without success. "datediff" function is not supported ?

May someone can help, thanks in advance

Select AP.AP_NEW_VALUE As "Status", count(TOTAL_BUGS) As "Weekly Defects", Sum(D1) As "Day 1", Sum(D2) As "Day 2", Sum(D3) As "Day 3", Sum(D4) As "Day 4", Sum(D5) As "Day 5", Sum(D6) As "Day 6", Sum(D7) As "Day 7"
FROM (SELECT AP.AP_NEW_VALUE, count(B.BG_BUG_ID) TOTAL_BUGS,
sum( case when datediff(DD, AL.AU_TIME, getdate()) <= 1 then 1 else 0 end) D1,
sum( case when datediff(DD, AL.AU_TIME, getdate()) <= 2 and datediff(DD, AL.AU_TIME, getdate()) > 1 then 1 else 0 end) D2,
sum( case when datediff(DD, AL.AU_TIME, getdate()) <= 3 and datediff(DD, AL.AU_TIME, getdate()) > 2 then 1 else 0 end) D3,
sum( case when datediff(DD, AL.AU_TIME, getdate()) <= 4 and datediff(DD, AL.AU_TIME, getdate()) > 3 then 1 else 0 end) D4,
sum( case when datediff(DD, AL.AU_TIME, getdate()) <= 5 and datediff(DD, AL.AU_TIME, getdate()) > 4 then 1 else 0 end) D5,
sum( case when datediff(DD, AL.AU_TIME, getdate()) <= 6 and datediff(DD, AL.AU_TIME, getdate()) > 5 then 1 else 0 end) D6,
sum( case when datediff(DD, AL.AU_TIME, getdate()) <= 7 and datediff(DD, AL.AU_TIME, getdate()) > 6 then 1 else 0 end) D7
FROM BUG B
INNER JOIN AUDIT_LOG AL on AL.AU_ENTITY_ID = B.BG_BUG_ID and AL.AU_ENTITY_TYPE='BUG' and AL.AU_ACTION='UPDATE'
INNER JOIN AUDIT_PROPERTIES AP on AP.AP_ACTION_ID = AL.AU_ACTION_ID and AP.AP_FIELD_NAME = 'BG_STATUS'
INNER JOIN (SELECT MAX(AL.AU_TIME) MY_TIME, AL.AU_ENTITY_ID MY_BUG_ID FROM AUDIT_LOG AL
INNER JOIN AUDIT_PROPERTIES AP on AP_ACTION_ID = AL.AU_ACTION_ID and AP.AP_FIELD_NAME = 'BG_STATUS' and AL.AU_ENTITY_TYPE='BUG' and AL.AU_ACTION='UPDATE'
GROUP BY CONVERT(VARCHAR,AU_TIME,101), AL.AU_ENTITY_ID) IJ on MY_TIME = AL.AU_TIME and MY_BUG_ID = B.BG_BUG_ID
WHERE Convert(VARCHAR, B.BG_DETECTION_DATE,101) between '09/23/2014' and '09/23/2014'
GROUP BY AP.AP_NEW_VALUE, AL.AU_TIME) MAP
GROUP BY AP.AP_NEW_VALUE


Viewing all articles
Browse latest Browse all 5491

Trending Articles