Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiply rows 1

Status
Not open for further replies.

blackduck

Programmer
Joined
Jun 11, 2002
Messages
119
Location
AU
Is there a way I can multiply each set of 12 data together eg. Prob for Match1 x Prob for Match2 x Prob Match3.

PosID TimeID MatchID WinID Prob
1 1 1 1 0.521739130434782
1 1 2 1 0.419754953864771
1 1 ..etc 1 0.427902390929258
1 1 12 1 0.461811324143505
2 1 1 1 0.521739130434782
2 1 2 1 0.419754953864771
2 1 ..etc 1 0.427902390929258
2 1 12 2 0.141259934443896

The end result would be something like if you used the aggregate function of sum, but instead I need to multiply.
 
If all your numbers are positive you can use:

Code:
select exp (sum (log (ColumnName)) from Table

pjm
 
It works! Fantastic. Big hug to ya! (and a star of course).

Sorry it took me awhile to get back, I didn't really understand it at first.

For anyone who wants an example, my sql code is:
SELECT tblProbablility.TimeID, tblPossible.PossibleID, Exp(Sum(Log([tblProbablility].[Probablility]))) AS ProductOfProbability
FROM tblPossible LEFT JOIN tblProbablility ON (tblPossible.WinnerID = tblProbablility.WinnerID) AND (tblPossible.MatchID = tblProbablility.MatchID)
GROUP BY tblProbablility.TimeID, tblPossible.PossibleID
HAVING (((tblProbablility.TimeID)<11));

If this looks a little hard. You can use design view, write the query with group/totals and use the sum aggregate until you get it right then instead of the sum column, you just put a new column and type in the field eg.
ProductOfProbability: Exp(Sum(Log([tblProbablility].[Probablility]))) making sure to select Expression where you would have had sum before.

But thanks again to pjm, you saved me heaps.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top