ISNULL in Where Clause does not return correct records in SQL Server

makumbi
 
on Aug 01, 2022 05:34 AM
396 Views

I am trying to return values but my select query returns wrong records

I want to return only p2, s but the return values contain other items.

please help

Select admno,Name,Class,Stream FROM science where   class = 'P2' and stream ='S' AND (Status IS NULL) OR (Status ='')
ORDER BY Science.Name;
admno Name Class Stream STATUS
22-00054 AGASHA ESTHER P2 S NULL
22-00053 MUHUMUZA DAVID P2 S NULL
22-00082 MUNGUJAKISA ELIJAH P2 S NULL
22-00056 MUSINGUZI SHUHAN P2 S NULL
22-00078 NAKATUDDE BRITINE P2 S NULL
22-00066 NAKIBONEKA KITRON P2 S NULL
22-00010 NALUBEGA HUDAH .K P2 N  
22-00050 NALUGWA ASHLEY P2 S NULL
22-00049 NAMUBIRU SHANICE P2 S NULL
22-00052 NANKUMBA ASHIMAT P2 S NULL
Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Aug 01, 2022 05:37 AM

Use below query.

SELECT admno,Name,Class,Stream 
FROM science 
WHERE class = 'P2' and stream ='S' AND ISNULL(Status,'') = ''
ORDER BY Science.Name;