Quantcast
Channel: The Big IBM i Blog – Nick Litten [IBM i AS400 iSeries] Software Developer
Viewing all articles
Browse latest Browse all 504

System21 - Phone numbers for any customers on sales orders

$
0
0
SQL Inner Join on AS400

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:

 

SELECT cusn05, dseq05, cnam05, phon05 

FROM slp05                            

WHERE EXISTS                          

(SELECT *                             

FROM oep40                            

WHERE slp05.cusn05 = oep40.cusn40)

 


Viewing all articles
Browse latest Browse all 504

Latest Images

Trending Articles



Latest Images