Multi Join FileMaker ExecuteSQL Query
ExecuteSQL ( "SELECT DISTINCT(a.Name), SUM(ii.x_Days) FROM Area AS a INNER JOIN Destination d ON d.\"_kf_area\" = a.\"__kp_Area\" INNER JOIN Accommodation accom ON accom.\"_kf_Destination\" = d.\"__kp_Destination\" INNER JOIN ItineraryItem ii ON ii.\"_kf_Accommodation\" = accom.\"__kp_Accommodation\" INNER JOIN Trip t ON t.\"__kp_Trip\" = ii.\"_kf_trip\" WHERE t.\"__kp_Trip\" = ? GROUP BY a.Name";":" ;" / " ; Trip::__kp_Trip )
I have a client with a database that was over engineered. Rather build a set of overly complex relationships to find this data I attempted my first multi inner join query with SQL. The result was highly successful! Greatly reducing the speeding on reporting pages.
The query finds country names, groups them by name, and sums the days the user is in country.