Hello Experts,

Today just isn't my day! I am trying to figure out how I can find the deviation from the linear regression through the use of custom made functions.

So far i have this...

___________________________________________________________________________

Option Compare Database

Function LinRegSlope(n, x, y, xy, xx)

'n = Count of items

'x = Sum of the X Axis

'y = Sum of the Y Axis

'xy = Sum of the X Axis * the Y Axis SUM(x*y)

'xx = x^2

LinRegSlope = ((n * (xy)) - ((x) * (y))) / ((n * (xx)) - ((x) * (x))) 'The slope of the line

End Function

Function LinRegYInt(n, x, y, xy, xx)

'n = Count of items

'x = Sum of the X Axis

'y = Sum of the Y Axis

'xy = Sum of the X Axis * the Y Axis SUM(x*y)

'xx = x^2

Dim m As Double ' Slope

m = ((n * (xy)) - ((x) * (y))) / ((n * (xx)) - ((x) * (x))) 'm = The slope of the line

LinRegYInt = (y - (m * x)) / n

End Function

________________________________________________________________________

This is working fine but my problem is the grouping. Is there a way i can use the SUM and at the same time find the deviation from an indivual record?

Thanks!

Select fld1, (select sum(amount1) from table1) as SumAmount

From table1