>>Hi everyone,
>>
>>Which of the commands below would execute faster assuming you have a million records and 200,000 of this records corresponds to the CUST_ID to compute the OrderAmount?
>>
>>1. (PRG)
>>
>>Local lnTotalOrder, lcCustID
>>
>>lnTotalOrder = 0
>>lcCustID = "0008"
>>
>>Seek &lcCustID
>>Do while Customer.Cust_ID=&lcCustID
>> lnTotalOrder = lnTotalOrder + Customer.OrderAmount
>> Skip
>>Enddo
>>Return (lnTotalOrder)
>>
>>
>>or
>>
>>2. (SQL)
>>
>>Select Customer.Cust_ID, sum(Customer.OrderAmount) As lnTotalOrder;
>>from Customer into cursor temp where Customer.Cust_ID="0008" Group by Customer.Cust_ID
>>
>
>The SQL statement indicates the data type of Cust_ID is character. Maybe I'm missing something but, if Cust_ID is character then both your SEEK and DO WHILE comparison should give a data type mismatch error since you are now seeking a numeric 8.
Good catch! He should just not use macro at all there.
>
>Also.......rather than doing a SCAN/ENDSCAN or DO WHILE, you might also try
>
>SUM OrderAmount TO lnTotalOrder FOR Cust_ID = lcCustID
Or, do the seek and then SUM while cus_id = m.lcCustID