partial returns SQL

I haev a script that looks and compares which product we truly received against what the client told us they send us. so they can tell us they are returning up to 20 product. I would like the script to tell me which client didnt return everything they said they would. I can't seem to get my and or statements to work.. I tried adding them in the where clause 2 different ways and neither of them worked... can someone save my sanity? I have been picking at this for an embarassing amount of time.

select *
into #openmaster3
from #openmaster2
where dvc1_rtrn='y' or dvc2_rtrn='y' or dvc3_rtrn='y' or dvc4_rtrn='y' or dvc5_rtrn='y' or dvc6_rtrn='y'
or dvc7_rtrn='y' or dvc8_rtrn='y' or dvc9_rtrn='y' or dvc10_rtrn='y' or dvc11_rtrn='y' or dvc12_rtrn='y'
  or dvc13_rtrn='y' or dvc14_rtrn='y' or dvc15_rtrn='y' or dvc16_rtrn='y' or dvc17_rtrn='y' or dvc18_rtrn='y'
   or dvc19_rtrn='y' or dvc20_rtrn='y'

then I tried

select *
from #openmaster3
where
(dvc1 is not NULL and dvc1_rtrn = 'n/a' ) or
(dvc2 is not NULL and dvc2_rtrn = 'n/a' ) or
(dvc3 is not NULL and dvc3_rtrn = 'n/a' ) or
(dvc4 is not NULL and dvc4_rtrn = 'n/a' ) or
(dvc5 is not NULL and dvc5_rtrn = 'n/a' ) or
(dvc6 is not NULL and dvc6_rtrn = 'n/a' ) or
(dvc7 is not NULL and dvc7_rtrn = 'n/a' ) or
(dvc8 is not NULL and dvc8_rtrn = 'n/a' ) or
(dvc9 is not NULL and dvc9_rtrn = 'n/a' ) or
(dvc10 is not NULL and dvc10_rtrn = 'n/a' ) or
(dvc11 is not NULL and dvc11_rtrn = 'n/a' ) or
(dvc12 is not NULL and dvc12_rtrn = 'n/a' ) or
(dvc13 is not NULL and dvc13_rtrn = 'n/a' ) or
(dvc14 is not NULL and dvc14_rtrn = 'n/a' ) or
(dvc15 is not NULL and dvc15_rtrn = 'n/a' ) or
(dvc16 is not NULL and dvc16_rtrn = 'n/a' ) or
(dvc17 is not NULL and dvc17_rtrn = 'n/a' ) or
(dvc18 is not NULL and dvc18_rtrn = 'n/a' ) or
(dvc19 is not NULL and dvc19_rtrn = 'n/a' ) or
(dvc20 is not NULL and dvc20_rtrn = 'n/a' )

February 12th, 2015 1:23pm

and I should have run spell check before clicking send.  *shakes head in Embarassement *
Free Windows Admin Tool Kit Click here and download it now
February 12th, 2015 1:23pm

Hi Sophie,

Since this issue is related to Transact-SQL, I will move this thread to Transact-SQL forum. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated. 

Thank you for your understanding and support.

Regards,
Katherine Xiong

February 13th, 2015 4:57am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics