>Several problems here:
>1. You use this as a field in result set:
> ALLT(STR(MONTH(DATE)))+ALLT(STR(YEAR(DATE))
>What if the first month of that result set is 1? then the whole field length will be 5 and at the end you can end with 12200 (Dec 200X). PAD it:
> PADL(ALLT(STR(MONTH(DATE)))+ALLT(STR(YEAR(DATE)),6,[0])
>
>2. use INNER JOIN instead of old WHERE. That makes code more readable:
>3. Do not use ALLTRIM() or EMPTY() in WHERE clause because there are not optimizable.
>4. I wonder HOW GROUP BY works if you didn't include in it the 3th selected field, but I suspect you have SET ENGINEBEHAVIUOR 70.
> Don't use this, you will get unexpected results from your queries.
>
>
>So lets go to SCAN ... ENDSCAN part:
>You never change the record pointer of C7 cursor so you ALWAYS update sCur with the same values over and over agein (depends how many records sCur has)
I thought sCur is a pseudonym for the c7. Otherwise good catch! I'm wondering why Beth didn't notice?
If it's not broken, fix it until it is.
My Blog