>Try
>Select T2.PK2, T2.PK1, T2.emp, T2.flag ;
> T2.PK1_Emp_Flag, - Sum(T2.Amt) as Amt ;
> from Table2 T2 ;
> WHERE T2.PK1_Emp_Flag NOT IN ( ;
> Select T1.PK1_Emp_Flag from Table1 T1 );
> GROUP BY T2.PK1_Emp_Flag ;
> INTO CURSOR crsRec4
This cut the time down to 1/3 as long.
It never accured to me that doing 2 selects could be faster than doing 1.
Now if I can only get it into a view, so I can update a field that triggers the addition of the new record, I'd be set.
>
>
>Select T2.PK2, T2.PK1, T2.emp, T2.flag ;
> T2.PK1_Emp_Flag, T1.Amt - Sum(T2.Amt) as Amt ;
> from Table2 T2 Join Table1 T1 ;
> on T2.PK1_Emp_Flag = T1.PK1_Emp_Flag ;
> GROUP BY T2.PK1_Emp_Flag ;
> HAVING Amt <> 0 ;
> INTO CURSOR crsRec56
>
This didn't save any time.
>
>>I'm current using 5.0a, but trying to find the time to upgrade to 7.0.
>>
>>I believe that SQL is my best option here, but certainly open to other ideas.
>>
>>My problem is that no matter what I try, the SQL takes too long to find what I'm looking for.
>>I've tried setting Exclusive on for tables being used.
>>I've tried adding/removing indexes.
>>I've tried packing the tables.
>>The SQL is still taking too long, and getting longer as we add more records.
>>
>>
>>I have 2 tables
>
>< snip >
Bill Morris