SELECT [MyTable].NewID, [MyTable].Patient,
(Count(*)*Sum([Date]*[weight])-Sum([Date])*Sum([weight])) /
(Count(*)*Sum([Date]^2)-Sum([Date])^2) AS Slope
FROM [MyTable]
GROUP BY [MyTable].NewID, [MyTable].Patient;
Was I supposed to define the date to be "in days" somewhere in the query? If so, how do I do that?
I would appreciate any help. Thanks.
----- Michel Walsh wrote: -----
Hi,
The COUNT and the SUM apply to the groups as defined in the GROUP BY clause.
A complete query could look like:
SELECT Id,
( COUNT(*)*SUM(x*y) -SUM(x)*SUM(y) ) /
(COUNT(*)*SUM(x^2)-SUM(x)^2) AS Slope
FROM MyTable
GROUP BY Id
Hoping it may help,
Vanderghast, Access MVP
Bonnie said:
Thanks for your reply, Mike. I haven't had much experience with
formulas.
Does the COUNT refer to all the weights, say for a distinct ID? I'm trying
to get the slope for many distinct IDs with many weights, each with
different date ranges so I can track any significant weight changes. I'll
try to apply this to my data. If you have any more helpful comments I'd
appreciate it.