f.martel
29th June 2011, 10:57
Ia orana !

In the code bellow, the average function return a long an not a double.



Declaration :

domain tcmcs.double moy

select lrilr047.sern,
avg(lrilr047.delta):moy
from lrilr047
where lrilr047._index1 = {:lrilr046.sern}
and lrilr047.datd between :date.f and :date.t
and lrilr047.data between :date.f and :date.t
group by lrilr047.sern
selectdo
endselect


For exemple, with the next values, the average is 3 an not 3.94
2,5,4,4,3,5,5,5,2,4,4,2,4,4,5,5

For information, the field lrilr047.delta is long.

Idea's ?

thank's

François

boXer14
29th June 2011, 12:36
Declaration :

domain tcmcs.double somme
domain tcmcs.double compteur
domain tcmcs.double moy

select lrilr047.sern,
sum(lrilr047.delta):somme, count(lrilr047.delta):compteur
from lrilr047
where lrilr047._index1 = {:lrilr046.sern}
and lrilr047.datd between :date.f and :date.t
and lrilr047.data between :date.f and :date.t
group by lrilr047.sern
selectdo
moy = somme/compteur
endselect

A essayer :)

Olivier

f.martel
29th June 2011, 12:40
Hello !

It's work !

Thank's / Merci :)

François