select OrderNumber
, Description
from Orders
left outer
join Invoice
on Orders.OrderNumber
= Invoice.OrderNumber
and Invoice.Status = 'C'
where Invoice.OrderNumber is null
Hi Rudy,
your query doesn't work if there's an order with both status = C and status <> 'C'.
A slight modification fixes it:
select distinct rderNumber
, o.Description
from orders o
left outer
join Invoice i
on rderNumber
= i.OrderNumber
where i.OrderNumber is null
or i.status <> 'c'
I couldn't find a single Exists query :-(
select *
from orders o
where not exists
(select * from invoice i
where rderNumber = i.OrderNumber
)
or
exists
(select * from invoice i
where rderNumber = i.OrderNumber
and i.Status <> 'C'
)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.