Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
TOTALing a child table
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00606502
Message ID:
00606511
Views:
18
Something like
SELECT ;
  BoIdBase, SUM(CallTot) AS CallTot ;
  FROM Details ;
  GROUP BY  1 ;
  INTO CURSOR DetSum 

INDEX ON BoIdBase TAG BoIdBase
SET ORDER TO BoIdBase 

SELECT LineItems
SET RELATION TO BoIdBase INTO Details
REPLACE LineItems.CallTot WITH DetSum.CallTot ;
  FOR FOUND("DetSum")
>I have a table, LineItems, which is related into Details:
>I scan through LineItems, and for each related child record, I
>total up a field called CallAct:
>
>
>SELECT LineItems
>SCAN
>
>  nTotal = 0
>
>  SELECT Details
>  IF NOT EOF()
>    DO WHILE NOT EOF()
>      nTotal = nTotal + Details.CallAct
>    ENDDO
>  ENDIF
>
>  REPLACE IN LineItems CallTot WITH nTotal NEXT 1
>
>ENDSCAN
>

>
>Anyone know how I can do this using SQL?
>
>Many thanks
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform