sql - select rows if order # not in 3rd table -


in below, trying select @ the, data selected in first part, should not exist in invoice table. want non invoiced.

# part 1    create view stock.clspayb2  select t02.ohcom#, t02.ohpttc, t02.ohslr#, t01.ottrt, t01.otord#, t02.ohord#, t01.ottrnd, t02.ohordt, t02.ohordd, t02.ohttn$, t02.ohhldc, t01.otusrn, t01.ottrnc  sales.oetranot t01 inner join stock.oeorhdoh t02     on       t01.otcom# = t02.ohcom#  ,        t01.otord# = t02.ohord#                 t01.ottrnc in ('bcs')  ,       t02.ohordd >= 20150101    # part 2. here issue:    , t02.ohord#       not in      (      select *      stock.oeinhdih t03       t02.ohord# = t03.ihord#     );                                          

you want either not in or not exists, you've mixed syntax two. use:

not exists (select 1             stock.oeinhdih t03              t02.ohord# = t03.ihord#            ) 

or, if prefer:

t02.ohord# not in (select t03.ihord# stock.oeinhdih t03) 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -