Previous Next

Presenting Data in a Cross Tab : Tutorial 6: Creating a cross tab : Task 3: Build a data set

Task 3:

In this procedure, you build a data set to indicate what data to extract from the Customers, OrderDetails, and Products tables.

1
2
Sales
3
n
n
4
Choose Next. Query displays the information to help you create a SQL query. The text area on the right side shows the required keywords of a SQL SELECT statement.
5
Use the following SQL SELECT statement to indicate what data to retrieve. You can type the column and table names, or you can drag them from Available Items to the appropriate location in the SELECT statement.
SELECT Customers.state,
Orderdetails.quantityOrdered,
Orderdetails.priceEach,
Products.productline
FROM Customers INNER JOIN Orders ON Customers.customerNumber
= Orders.customerNumber
INNER JOIN Orderdetails ON Orders.orderNumber = Orderdetails.orderNumber
INNER JOIN Products ON Orderdetails.productCode = Products.productCode
WHERE Customers.country = 'USA'
This SELECT statement joins four tables to get the required data.
6
Choose Finish to save the data set. Edit Data Set displays the columns specified in the query, and provides options for editing the data set.
7
Choose Computed Columns, then choose New to create a computed field that calculates extended prices by multiplying values from the QUANTITYORDERED and PRICEEACH fields.
8
1
EXTENDED_PRICE
2
3
row["QUANTITYORDERED"] * row["PRICEEACH"]
Alternatively, you can open the expression builder to construct the expression by selecting the appropriate data set fields. Note that unlike the SELECT statement where you can type table field names in any case, data set field names are case-sensitive. If, in Expression, you typed row["quantityOrdered"], BIRT displays an error when you preview the results returned by the data set.

Figure 17-2 Computed field EXTENDED_PRICE

Figure 17-2
Computed field EXTENDED_PRICE
4
9
Choose Preview Results to confirm that the query is valid and that it returns the correct data. If you created the SELECT statement and computed field correctly, you see the results that appear in Figure 17‑3. These are the data rows that the query returns.

Figure 17-3 Preview of rows returned by the Sales data set

Figure 17-3
10

(c) Copyright Actuate Corporation 2008