hi,
the records are look like this:
d
branch | doctor | days from today | free time minutes |
---|
a | a | 1 | 15 |
a | a | 1 | 30 |
a | a | 2 | 90 |
a | a | 3 | 60 |
b | c | 1 | 60 |
b | c | 2 | 30 |
b | c | 2 | 40 |
b | d | 4 | 90 |
by branch and doctor I need to show the average(avg) of the closest X free turn larger then Y minutes
for example for
X=3
Y=30
doc a in branch a its (1+2+2)/3=1.66 (1=its for the second row,2+2 its the next two chunks of 30 min from the row of 90 minutes free.
for doc c in branch b its (1+1+2)/3=1.3
for doc d in branch b its (4+4+4)/3=4
X and Y are input fields!!
and can be changed by the user online.
so whay needed is accumulative calculations on the fly on this records...
to get the results like this:
branch | doctor | average free day from today |
---|
a | a | 1.66 |
c | b | 1.3 |
b | d | 4 |
you can imagine that the real data is thousands of doctors and like handers of branches...
thanks for any help
Doron