I would be most grateful if someone could help me with the following problem which I would have been able to do in a flash 30 years ago!
I have a table which has six fields (rprize1 through rprize6) which occur on up to 10 records for specific date and I am able to aggregate them successfully with the following query through VBA :-
I would like to aggregate them further (ie summing each Prizetot and each 1) for as many records that occur in the year.
I have tried with :-
but keep getting Syntax error in JOIN operation.
Where am I going wrong?
I have a table which has six fields (rprize1 through rprize6) which occur on up to 10 records for specific date and I am able to aggregate them successfully with the following query through VBA :-
Code:
StrSQL = "SELECT R.rfj, C.cname, R.rcourseid, SUM(R.rprize1 + R.rprize2 + R.rprize3 + R.rprize4 + R.rprize5 + R.rprize6) As Prizetot,1 " & _
"FROM race as R, course as C " & _
"WHERE Year(R.rdate) = 2017 " & _
" AND C.cid = R.rcourseid " & _
"GROUP BY R.rfj, C.cname, R.rcourseid, Cname&rdate "
I would like to aggregate them further (ie summing each Prizetot and each 1) for as many records that occur in the year.
I have tried with :-
Code:
StrSQL = "SELECT TblMeet.rfj, TblMeet.Cname, TblMeet.rcourseid, SUM(TblMeet.Prizetot), SUM(TblMeet.Mtg) " & _
"FROM (TblMeet " & _
" LEFT JOIN " & _
"(SELECT R.rfj, C.cname, R.rcourseid, SUM(R.rprize1 + R.rprize2 + R.rprize3 + R.rprize4 + R.rprize5 + R.rprize6) As Prizetot, 1 as Mtg " & _
"FROM race as R, course as C " & _
"WHERE Year(R.rdate) = 2017 " & _
" AND C.cid = R.rcourseid " & _
"GROUP BY R.rfj, C.cname, R.rcourseid, Cname&rdate) as Mmeet ON TblMeet.rfj = Mmeet.rfj AND TblMeet.Cname = Mmet.Cname AND TblMeet.rcourseid = Mmeet.rcourseid) "
Where am I going wrong?