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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiplying rows

Status
Not open for further replies.

alh1002

Technical User
Mar 27, 2006
41
US
I have a table, with dates and corresponding percentages. I want to multiply all the percentages together that are in a particular time span. So if the span is short this could be multiplying two rows together, but it could be 100 of rows together.

How can I do this?
 
Assuming that the percentages are of the form 0.75 (equivalent to 75%)
Code:
Select Exp(SUM(Log([Percentage])) As [ProductOfPercent]

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
I am trying to do a "complicated" query

The Select Exp(SUM(Log([Percentage])) As [ProductOfPercent]
is coming from a two different queries.

and I get an error saying it is to complicated

How can I refine it

below are the queries


end query
Select Exp(SUM(Log([gMTDPER]))) As [Prod]
FROM qry_MTD_RT;


middle query

SELECT A.ladder_date, A.book_name, A.gMTDRT, A.gMTDPER
FROM RT_book_daily_p1 AS A INNER JOIN [SELECT Year([ladder_date]), Month([ladder_date]),
MAX([ladder_date]) AS LastDay
FROM RT_book_daily_p1
GROUP BY Year([ladder_date]), Month([ladder_date])]. AS L ON A.ladder_date = L.LastDay;


Base query

SELECT tblNAV.book_name, tblNAV.ladder_date, tblBOM.BOM AS BOM, tblNAV.NAV AS NAV, NAV-BOM AS gMTDRT, 100*gMTDRT/BOM AS gMTDPER, (Select Top 1 Val(Nz([A.NAV],[tblBOM.BOM])) From tblNAV A Where A.ladder_date<tblNAV.ladder_date and (((DatePart("m",[A.LADDER_DATE]))=DatePart("m",[tblBOM.BOM_DATE])) AND ((DatePart("yyyy",[A.LADDER_DATE]))=DatePart("yyyy",[tblBOM.BOM_DATE]))) Order By ladder_date Desc) AS PreviousDay, Val(Nz([PreviousDay],[tblBOM.BOM])) AS Base, [NAV]-Val(Nz([PreviousDay],[tblBOM.BOM])) AS gTDRT, 100*(gTDRT/(Val(Nz([PreviousDay],[tblBOM.BOM])))) AS gTDCHANGEPER
FROM tblNAV INNER JOIN tblBOM ON tblNAV.book_name=tblBOM.BOM_book_name
WHERE (((tblNAV.book_name)=[what book?]) AND ((DatePart("m",[tblNAV.LADDER_DATE]))=DatePart("m",[tblBOM.BOM_DATE])) AND ((DatePart("yyyy",[tblNAV.LADDER_DATE]))=DatePart("yyyy",[tblBOM.BOM_DATE])));



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top