Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Syntax - Grouping

hi all - using VS 2003 and MS Reporting Services.

The following is my code:

SELECT CallNumber, LogDatTim, FirstName, LastName, CallSubject1 AS Service, CallSubject2 AS Category, CallSubject3 AS Item
FROM dbo.Call
WHERE (LogDatTim >= @fromDate + ' 00:00') OR
(CallSubject3 = 'User Leaving') OR
(CallSubject3 = 'Disable Future') OR
(CallSubject3 = 'Disable Now')
ORDER BY LastName, FirstName

I need it to choose the LogDatTim first from a criteria window - eg 1/10/2005 and bring up any of the CallSubject3 within that time.

what it seems to be doing is picking up all calls after 1/10/2005 as well as any calls with CallSubject3 - eg I am also collecting 2002 calls with the subject in.

I did try an AND before the first CallSubject but that didn't help either.

How do I bracket this please.

thanks
[1014 byte] By [jewel] at [2007-11-11 7:14:31]
# 1 Re: Syntax - Grouping
When you tried the AND did you enclose all the ORs of call subject 3 into one paranthesis ?
(
(LogDatTim >= @fromDate + ' 00:00')
AND
(
(CallSubject3 = 'User Leaving') OR
(CallSubject3 = 'Disable Future') OR
(CallSubject3 = 'Disable Now')
)
This should work
srinivas_s at 2007-11-11 23:47:49 >