how to realize the function as order by in SQL

feilong
feilong Member Posts: 6
Dear all,
I am working on a customer report. The aim is get all Bill-to Customer No. , then get the all Customer records related to the Bill-to Customer No. and order by Name.
If described in SQL is:
SELECt customer.* FROM customer WHERE customer.id IN (SELECT distinct(Bill-to Customer No.) FROM customer) ORDER BY name

Any suggestion and advice is appreciated.

Comments

  • Arjan
    Arjan Member Posts: 7
    Create a temporary table based on the Customer table.

    Fill that with code like this while running through the sales headers:

    Cust.Get("Bill-to Customer No.");
    TempCust.TRANSFERFIELDS(Cust);
    if TempCust.INSERT THEN; //only insert if not exists.


    TempCust.SETCURRENTKEY("Search Name"); //search name is normally same as Name

    Then read the temporary table in an Integer dataitem to print it.
  • feilong
    feilong Member Posts: 6
    Arjan, thanks a lot. Without you help, I wont finished the report so quickly. =D>