Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
SQL
Miscellaneous
Thread ID:
00328952
Message ID:
00328952
Views:
68
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
Next
Reply
Map
View

Click here to load this message in the networking platform