Along the same vein as the questions asked yesterday, I have another "count if" dilemma. Now I need to pull a count of the condition entries that meet the following parameters:
- ConditionLevelEntryID = 189
- CheckoffDate is > 14 days from ConditionEntryDateTime
- CheckoffDate IS NULL and ConditionEntryDateTime is > 14 days old
I have attempted the query (below) which doesn't work. The error returned is below the query. Please help me refine the query to get an accurate count. Thanks in advance.
select Count(*)
from conditionentrytable c
where conditionlevelentryid=189
and
((c.checkoffdate IS NULL
and
convert(varchar(12),DATEADD(day,14,c.conditionentrydatetime)))
or
DATEDIFF(dd,c.checkoffdate,c.conditionentrydatetime)>14)
Server: Msg 170, Level 15, State 1, Line 7 Line 7: Incorrect syntax near ')'.