April 13, 2008 at 5:05 pm
This is what I have but keeps getting error, I have this report I need to generate by Urgency, group and the age of the incident by open date
this is what I have
select
[Incident #],
[Urgency ID],
[Group Name],
Open Date & Time],
[_SMDBA_.Incident_Age = datediff] (d, [Open Date & Time], getdate())-----ERROR is at this line
from [_SMDBA_.Incident_Age
where [Open Date & Time] > '2007-1-1' and [Close Date & Time]= NULL
and [Group Name] = 'NOC'
group by [Group Name] , [Urgency ID],[_SMDBA_.Incident_Age]
Can anyone hep Thanks
April 13, 2008 at 9:33 pm
I see some syntax mistakes. Here is the correct one try running this..
if you still get any error please post error too..
select
[Incident #],
[Urgency ID],
[Group Name],
[Open Date & Time],
[_SMDBA_.Incident_Age] = datediff(d, [Open Date & Time], getdate())-----ERROR is at this line
from [_SMDBA_.Incident_Age]
where [Open Date & Time] > '2007-1-1' and [Close Date & Time]= NULL
and [Group Name] = 'NOC'
group by [Group Name] , [Incident #],datediff (d, [Open Date & Time], getdate()),[Open Date & Time]
NJ
April 14, 2008 at 12:47 am
And if "= NULL"
do not work, try "IS NULL" instead.
N 56°04'39.16"
E 12°55'05.25"
April 14, 2008 at 7:36 am
Davidyard
One step at a time: introduce the aggregate last.
SELECT
[Incident #],
[Urgency ID],
[Group Name],
[Open Date & Time],
[SMDBA_Incident_Age] = DATEDIFF(d, [Open Date & Time], GETDATE())-----ERROR is at this line
FROM [_SMDBA_].[Incident_Age]
-- Is this really the name of the owner and table?
-- It looks like a table name and column name: try FROM [_SMDBA_]
WHERE [Open Date & Time] > CONVERT(DATETIME,'2007-01-01 00:00:00.000',20) -- Probably need >=
AND [Close Date & Time] IS NULL
AND [Group Name] = 'NOC'
-- group by [Group Name] , [Urgency ID], [_SMDBA_.Incident_Age] -- Bring in aggregate when the rest of the query is working
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply