>>>You can get your sums from each table into cursors and then join all these cursors together for your final result to get total sum.
>>
>>Naomi, I have the following questions about your SQL query and want to thank you, Steve
>>
>>select ;
>>NVL(T1.RatingSum,0) + NVL(T2.RatingSum) as TotalRating, ;
>>NVL(T1.yymmddhh, T2.yymmddhh) AS yyMMddhh ;
>>FROM ;
>>( ;
>>select ;
>>sum(mRating) as RatingSum, ;
>>LEFT(mDate,10) as yyMMddhh ;
>>from Table1 ;
>>GROUP BY 2 ;
>>) ;
>>T1 ;
>>FULL JOIN ;
>>( ;
>>select ;
>>sum(mRating) as RatingSum, ;
>>LEFT(mDate,10) as yyMMddhh ;
>>from Table2 ;
>>GROUP BY 2 ;
>>) ;
>>T2 ;
>>ON T1.yymmddhh = T2.yymmddhh
>>
>
>Group by 2 means group by the second column (in our case it's computed column without the minutes part). In VFP we can not use computed column in the GROUP BY expression (as in SQL Server), so we have to use the ordinal number of the column.
>
>The query above sums first by hour in Table1 and Table2 and then uses a FULL JOIN (in case there may be rows in one table and not in another) between these two derived tables to get the total sum.
Should I be able to test each of the selects separately, starting from the bottom? In the top select, does the line
NVL(T1.RatingSum,0) + NVL(T2.RatingSum) as TotalRating, ;
presuppose that a field named RatingSum already exists, or can it be a field that is defined in this query
Thanks
Steve