Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Statistical Function : MEDIAN
Message
 
 
À
10/12/2001 09:29:43
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00592035
Message ID:
00592047
Vues:
16
>>Hi all
>>
>>Does anyone has a function to calulate MEDIAN for VFP?
>>
>>Thanks in advance
>>Petros
>
>That is the value in the middle, right?
>
>Here is a sample:
>
>
>select MyValue from MyTable into cursor Temp;
>  order by MyValue;
>  nofilter
>goto reccount() / 2
>? MyValue
>
>
>HTH, Hilmar.

It's little bit more complicated. :)
lnRecCnt = RECCOUNT()
IF (lnRecCnt % 2 ) =1       && Odd # of records
    GOTO ( CEILING( lnRecCnt/2 ) )
    lnMedian = MyValue
ELSE
    GOTO ( lnRecCnt/2  )
    lnMedian = MyValue
    SKIP
    lnMedian = (lnMedian + MyValue) / 2
ENDIF
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform