I am trying to perform a conditional sum on a column of data in a FoxPro program. I think it should be able to be done in one line or so. So far I have something that looks like:
public sumvar
sumvar = SUM(TABLE2.val WHERE table2.id = table1.id)
This is being done inside a loop, so for this instance, table1.id might equal 4, and there are say 3 rows in table2 which have table2.id = 4. So I want to sum the table2.val value for just these 3 rows together. Any help much appreciated!