Bowman Systems L.L.C. ADVANCED REPORTING TOOL INNER AND OUTER JOINS This document and the information contained herein are the property of Bowman Systems L.L.C and should be considered business sensitive. Copyright 2005 Bowman Systems L.L.C 333 Texas Street Suite 300 Shreveport, LA 71101 (318) 213-8780 Bowman Systems L.L.C. v08.21.05 Page 1 of 1 INNER JOINS Inner joins find the intersection (in the mathematical sense) between two tables. Therefore if Table A and Table B are queried via an inner join, only the rows in Table A that have a corresponding row in Table B are returned. For example, consider the two following tables: Client ID First Name Last Name 1 John Smith 2 Jane Smith Service ID Client ID Cost Date 100 1 344.01 01/01/01 101 1 234.56 02/02/02 If these two tables are joined via an inner join (in this instance using the Client ID field), then only two rows pertaining to John Smith will be returned. Jane Smith has no service records, thus no rows pertaining to her are returned when the tables are joined via an inner join. Client ID First Name Last Name Service ID Cost Date 1 John Smith 100 344.01 01/01/01 1 John Smith 101 234.56 02/02/02 OUTER JOINS Outer joins show the results between two tables, even if one of the tables does not have corresponding rows in the other table. For example, if we joined the two tables above, but specified that the services table was to be queried using an outer join, the following table would result: Client ID First Name Last Name Service ID Cost Date 1 John Smith 100 344.01 01/01/01 1 John Smith 101 234.56 02/02/02 2 Jane Smith The Service ID and Cost rows would contain a “NULL” value as no service data exists for Jane. Bowman Systems L.L.C. v08.21.05 Page 2 of 2 FILTERS AND OUTER JOINS It is often unnecessary to apply filters to outer joined tables. For example, when building a report with the client last name “Smith” and all of the services they received in the first quarter of 2001. It may seem that this report can be generated by simply placing a filter on the “Date” field that restricts rows from the Service table to those which have a date after 12/31/2000 and before 4/1/2001. However the report generated using this query/filter would appear as follows: Client ID First Name 1 John Last Name Smith Service ID 100 Cost 344.01 Date 01/01/01 Although the Service table is linked via an outer join, there is no row for Jane in the results of this query. The filter is preventing Jane's row from being returned. It specifies that only rows which have a date within a specific range should be returned. Because Jane has no service records and therefore no “Date” field, no data displays for Jane. The filter must be modified to account for this omission. Instead of simply creating a filter with a date range, the filter should include other options, such as “null.” The filter should look like this: “Service table “Date” field must have a date after 12/31/2000 and before 4/1/2001 OR Service table “Date” field must “NULL”” By explicitly allowing the “NULL” value for the date field, Jane's row will be included in the results: Client ID First Name Last Name 1 John Smith 2 Jane Smith Service ID 100 Cost 344.01 Date 01/01/01 © 2005 Bowman Systems L.L.C. All Rights Reserved. ServicePoint and the ServicePoint logo are trademarks of Bowman Internet Systems, L.L.C. All other brand or product names are trademarks or registered trademarks of their respective holders. Bowman Systems 333 Texas Street, Suite 300 Shreveport, LA 71101 Toll Free: (888) 580-3831 Direct: (318) 213-8780 Fax: (318) 213-8784 http://www.bowmansystems.com Bowman Systems L.L.C. v08.21.05 Page 3 of 3