Creating a query to link three tables
Most times, we need to extract data from multiple tables; so, it's very important to understand how to join multiple tables. In this recipe, we will see how to join three tables, set up the method to calculate totals, and add filters to limit the result.
How to do it...
Create a new query object with Object Designer.
In Query Designer, choose
DataItem
from the drop-down list in theType
column.Select
Currency
as aData Source
value from the table list.In next row, select
Column
asType
andCode
asData Source
. Keep the methodNone
as it is.In the next row, select
DataItem
in theType
column andSales Invoice Header
in theData Source
column.In the next row, select
DataItem
in theType
column andSales Invoice Line
in theData Source
column.Add one more row with
Column
asType
andAmount
asData Source
. For this row, changeMethod Type
toTotals
andMethod
toSum
.Maintain the indentation of all rows as shown in the following screenshot:
To set up a relation...