Reputation: 55
I have the problem to retrieve the query with statement AND OR
SELECT *
FROM [DPPLBMS].[dbo].[STUDENTS_DETAILS]
where AttendingConvocation='0' and (grade = 'A') or (grade='B') or (Grade='C')
Im trying the view the data with Attending Convocation = 0 and grade is A, B & C only.
The result is show both records, Attending Convocation show records 0 = Not Attend and 1 = Attend Convocation
Upvotes: 1
Views: 65
Reputation: 1473
Try this.
SELECT * FROM [DPPLBMS].[dbo].[STUDENTS_DETAILS]
where AttendingConvocation='0' and (grade = 'A' or grade='B' or Grade='C')
Or even better maybe:
SELECT * FROM [DPPLBMS].[dbo].[STUDENTS_DETAILS]
where AttendingConvocation='0' and grade in ('A', 'B', 'C')
Upvotes: 2