During a meeting this morning, I was asked to provide a list of all Customer phone numbers for any System21 Customers that have ever been used on a Sales Order.
Perhaps this sounds like a complicated request but... have no fear SQL is here!!! In reality, its a very simple thing to find and takes just a few seconds using a SQL INNER JOIN.
How can we use SQL to find this data?
In this example, I'm working on a data cleanse to make sure that the phone numbers are properly formatted before sending them to FEDEX as part of the shipment information. We know that some of our data is badly formatted so lets quickly see how many are good, bad or ugly. Using SQL we can see all CUSTOMER entries from the Customer Master file (SLP05) which have been referenced on the Sales Order Header file (OEP40).
The SQL command goes like this:
FROM slp05
WHERE EXISTS
(SELECT *
FROM oep40
WHERE slp05.cusn05 = oep40.cusn40)