I hope i am missing out something very silly. Help Me...

Hi Everybody,
Below is my requirement;
say after joining 2 tables customer & order i have 3 fields in the result set as follows;
1. Customer ID
2. Customer Name
3. Order Number

Pre-Requisites:
1. In order table Order number is not unique, it may repeat

Now i need to Break By Order number but should be sorted based on customer id and then by order number.

Please validate the below solution and let me know if there is a better way,

FOR EACH customer,
EACH order BREAK BY NAME:
IF FIRST-OF(NAME) THEN
DO:
/** populate the value to a temp-table; say newTable */
END.
END.

FOR EACH newTable BY customerid:
/** display the records now **/
END.
 

TomBascom

Curmudgeon
Why wouldn't you:

Code:
for each customer no-lock,
     each order no-lock /* where order.custId = customer.custId ??? */
     break by customer.customerId by order.orderNum

  display
    customer.customerId
    customer.customerName
    order.orderNum
  .

end.
 

StuartT

Member
You really need a where clause such as the one in Toms example otherwise you are doing a full pass of EVERY order on the system for every customer which would mean a huge amount of replication.
 
Top