Wednesday, October 29, 2014

SQL Query MOJO - Use Excel to build a redundant query

From time to time, I find it necessary to create a query, which has a redundant element.  Something like a user hands me an Excel based list, which contains customer email addresses...  I am sure I am not the first person to figure this out, but I was quite pleased with myself when I did.

It is possible to use Excel's concatenation feature to build a redundant query. In the example below, I was asked by a new controller to tell them what the first year each company database was placed in use, at an organization which had dozens of company databases.  I did a simple select statement for INTERID on the SY01500 table to create a list of company database ID's as a foundation for this query. 

I then pasted the ID's into Excel and wrote a query using the list field to pull the first financial year from each database.  The list of databases in my test system is short, and I don't want to publish a client's list of company database ID's so my example only includes two databases. 

No comments:

Post a Comment