|
sz1
Constraint Violating Yak Guru
United Kingdom
294 Posts |
Posted - 01/09/2013 : 10:02:00
|
Is is possible to requery this query that a week old, so -7 days less from Occurred_DT calculate all tickets in open status - 7 days from current day? I tried putting -7 days after the datediff but this only subtracts 7 days from the open days total not the overall open calls. It needs to not count calls older than a week old only so discount last 7 days from Occurred_DT.
Ta
select distinct [ID],c.DESC_SHORT,c.STATUS_NAME, c.OCCURED_DT AS "Open Date", DATEDIFF(d, c.OCCURED_DT, GETDATE()) AS "Open Days", AVG(DATEDIFF(d, c.OCCURED_DT, GETDATE())) AS "Day Average", c.ASSIGNED_GRP_NAME, c.ASSIGNED_REP_NAME, c.PRIORITY_NAME, TYPE, [SYMPTOM], [CONTACT_FIRST_NAME] + ' ' + [CONTACT_LAST_NAME] AS "Contact Name", INTI_CATEGORY from DIM_CALL c where c.OPEN_FLAG = 1 and c.ETL_CURRENT =1 AND TYPE ='Incident' AND STATUS_NAME Not In ('Resolved','Resolved Change','Transfer to Problem') AND [ID] <> 5193
--and c.ASSIGNED_REP_NAME in (@User) Group By [ID], c.DESC_SHORT, c.STATUS_NAME, c.OCCURED_DT, c.ASSIGNED_GRP_NAME, c.ASSIGNED_REP_NAME, c.PRIORITY_NAME, TYPE, SYMPTOM, CONTACT_FIRST_NAME, CONTACT_LAST_NAME, INTI_CATEGORY
Order by "Open Days" DESC, c.OCCURED_DT
SZ1 Learning and development is the driving force in the universe...! |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47173 Posts |
Posted - 01/09/2013 : 22:39:16
|
add below to where
AND c.OCCURED_DT > DATEADD(dd,DATEDIFF(dd,0,GETDATE()),-7)
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|