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 |
sz1
Aged Yak Warrior
555 Posts |
Posted - 2013-01-09 : 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.Taselect 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_CATEGORYfrom DIM_CALL cwhere c.OPEN_FLAG = 1 and c.ETL_CURRENT =1AND 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_CATEGORYOrder by "Open Days" DESC, c.OCCURED_DTSZ1Learning and development is the driving force in the universe...! |
|
djj55
Constraint Violating Yak Guru
352 Posts |
Posted - 2013-01-09 : 10:55:36
|
Try adding a dateadd to the where clause. Something like:AND c.OCCURED_DT <= DATEADD(d, -7, GETDATE()) djj |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-09 : 22:39:16
|
add below to whereAND c.OCCURED_DT > DATEADD(dd,DATEDIFF(dd,0,GETDATE()),-7)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|