Previous Next

Task 11:  Display only customers that have orders or payments

The database contains customers that do not have orders or payments. The query for the customers report returns all customers. When you run the report, there are customer rows that show only the column headings for the Orders and Payments tables, as shown in Figure 12-23.

Figure 12-23 Report showing no order or payment data for one customer

Figure 12-23  Report showing no order or payment data for one customer

You can exclude customers that do not have orders or payments by changing the query for the customers report.

1  
2  
3  
  WHERE
  EXISTS
  (SELECT Orders.customerNumber
  FROM Orders
  WHERE Customers.customerNumber =
  Orders.customerNumber)
  OR
  EXISTS
  (SELECT Payments.customerNumber
  FROM Payments
  WHERE Customers.customerNumber =
  Payments.customerNumber)
The WHERE EXISTS clause checks the Orders and Payments tables for customerNumber values that match the customerNumber values in the Customers table. Only rows that have matching customerNumber values are selected. The complete query should look like the one shown in Figure 12-24.

Figure 12-24 Updated SELECT query in Edit Data Set

Figure 12-24  Updated SELECT query in Edit Data Set
4  
5  

(c) Copyright Actuate Corporation 2013