Skip to main content
added 196 characters in body
Source Link
paparazzo
  • 6k
  • 3
  • 19
  • 41

I think this does what you are looking for (more efficiently)

 SELECT disticnt PolicyNumber
 FROM tblClassCodesPlazaCommercial 
 where not exist ( select 1 
                   from tblClassCodesPlazaCommercial
                   where ClassCode NOT IN (@ClassCode) ) 

Original code

SELECT  PolicyNumber
FROM    tblClassCodesPlazaCommercial 
GROUP BY PolicyNumber
HAVING COUNT (CASE WHEN ClassCode NOT IN (@ClassCode) THEN 1 END) = 0

I think this does what you are looking for (more efficiently)

 SELECT disticnt PolicyNumber
 FROM tblClassCodesPlazaCommercial 
 where not exist ( select 1 
                   from tblClassCodesPlazaCommercial
                   where ClassCode NOT IN (@ClassCode) ) 

I think this does what you are looking for (more efficiently)

 SELECT disticnt PolicyNumber
 FROM tblClassCodesPlazaCommercial 
 where not exist ( select 1 
                   from tblClassCodesPlazaCommercial
                   where ClassCode NOT IN (@ClassCode) ) 

Original code

SELECT  PolicyNumber
FROM    tblClassCodesPlazaCommercial 
GROUP BY PolicyNumber
HAVING COUNT (CASE WHEN ClassCode NOT IN (@ClassCode) THEN 1 END) = 0
Source Link
paparazzo
  • 6k
  • 3
  • 19
  • 41

I think this does what you are looking for (more efficiently)

 SELECT disticnt PolicyNumber
 FROM tblClassCodesPlazaCommercial 
 where not exist ( select 1 
                   from tblClassCodesPlazaCommercial
                   where ClassCode NOT IN (@ClassCode) )