Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Re: SQL
Miscellaneous
Thread ID:
00328952
Message ID:
00329134
Views:
23
>Hello,
> I have the following sql statement which is not working properly. It doubles up the total for the fields that I want to sum:
> SELECT OUT.*,
> SUM(IIF(RPT_YEAR = "1997",PL_TOT,000000)) AS P97,;
> SUM(IIF(RPT_YEAR = "1997",CL_TOT,000000)) AS C97,;
> SUM(IIF(RPT_YEAR = "1997",TOTAL,000000)) AS T97,;
> SUM(IIF(RPT_YEAR = "1998",PL_TOT,000000)) AS P98,;
> SUM(IIF(RPT_YEAR = "1998",CL_TOT,000000)) AS C98,;
> SUM(IIF(RPT_YEAR = "1998",TOTAL,000000)) AS T98, ;
> SUM(IIF(RPT_YEAR = "1999",PL_TOT,000000)) AS P99,;
> SUM(IIF(RPT_YEAR = "1999",CL_TOT,000000)) AS C99,;
> SUM(IIF(RPT_YEAR = "1999",TOTAL,000000)) AS T99 ;
> FROM BROKPROD,OUT;
> WHERE BROKPROD.AG_ID = OUT.AG_ID ;
> GROUP BY BROKPROD.AG_ID ;
> ORDER BY BROKPROD.AG_ID ;
> INTO TABLE &OUTPUT
>Can anyone tell me what I did wrong ??
>thanks
>sherry

If all the sums are doubled I'd say that for each BROKPROD.AG_ID there are two OUT.AG_ID matches (or vice versa) - you could try to browse the record set without the SUMs and GROUP BY clause.
Doru
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform