September 15, 2006 at 9:40 am
I need some assistance. I appear to be having a brain fart at the moment and just can't seem to get the results I'm looking for. Here's my basic dilema:
I've got 2 tables in a SQL 2000 Database, ARDoc and Shippers... Both tables have a common order number field (OrdNbr) as well as Invoices (InvcNbr in Shippers and RefNbr in ARDoc). In some cases, the invoices between the 2 tables do not match. I need to be able to get a result set for the order numbers that do not have matching Invoice numbers. Any assistance is greatly appreciated.
September 15, 2006 at 10:03 am
Select ARDoc.OrdNbr from ARDoc
left outer join Shippers
on ARDoc.OrdNbr = Shippers.OrdNbr
where Shippers.InvcNbr ARDoc.RefNbr
September 15, 2006 at 10:31 am
Just making it cleaner:
Select ARDoc.OrdNbr from ARDoc
left outer join Shippers on ltrim(rtrim(ARDoc.OrdNbr)) = ltrim(rtrim(Shippers.OrdNbr))
where isnull(ltrim(rtrim(Shippers.InvcNbr)),'') <> isnull(ltrim(rtrim(ARDoc.RefNbr)),'')
September 18, 2006 at 10:37 pm
Yes, it makes more sense to use the trim functions when you have the columns that allow even the character datatypes.
Prasad Bhogadi
www.inforaise.com
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply