Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Summarize table
Message
From
17/08/2008 00:02:13
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01339319
Message ID:
01339335
Views:
14
This message has been marked as a message which has helped to the initial question of the thread.
>I am trying this code to sumarize de credits and date of table 1 into
>credit and legend of cursorTemp, where legend = month name
>
>I am using the code below but it is not working:
>
>
>SELECT table1
>SCAN
> SELECT tempCursor
> LOCATE FOR tempCursor.CLEGEND = CMONTH(table1.date)
> IF NOT FOUND()
>
> APPEND BLANK IN tempCursor
> replace tempCursor.credit WITH table1.credit
> replace tempCursor.cLegend WITH CMONTH(table1.data)
>
>ELSE
> REPLACE tempCursor.CREDIT WITH tempCursor.credit + table1.CREDIT
> replace tempCursor.cLegend WITH CMONTH(table.date)
>
> ENDIF
>
>ENDSCAN

Except the for typo Alan mentioned (table1.data), and the typo he missed (table.date) your code seems to work. I think you could get the same thing with
SELECT CMONTH(date) clegend,sum(credit) credit FROM table1 GROUP BY 1;
     INTO CURSOR tempCursor
although that would change the order of the records into alpha by month.
If you need it in calendar order you could try....untested, I don't have VFP 9 on this machine
SELECT clegend,credit;
    FROM(SELECT MONTH(date), MAX(CMONTH(date)) clegend,sum(credit) credit FROM table1 GROUP BY 1);
    INTO CURSOR tempCursor
Previous
Reply
Map
View

Click here to load this message in the networking platform