median. Bill. is this good solution???

# Thread: median. Bill. is this good solution???

1. Senior Member
Join Date
Dec 1969
Posts
188

## median. Bill. is this good solution???

Thanks for your response. I had a solution to find median using 3 fields from database, but was trying to find a better one. This is what I am trying now.<BR><BR>I have 3 fields(numbers) - A,B and C <BR>if statement using 6 combinations using numbers 1,2 and 3<BR>A,B,C<BR>1,2,3-if A&#060;B and B&#060;C and A&#060;C then median is B<BR>1,3,2-elseif A&#060;B and B&#062;C and A&#060;C then median is C<BR>2,1,3-elseif A&#062;B and B&#060;C and A&#060;C then median is A<BR>and three other combination.<BR><BR>I thinks this will do the trick!!!<BR>

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## RE: median. Bill. is this good solution???

Sigh. I had thought you meant the median of three fields from ALL records in a RecordSet! You just want the median for *ONE* record.<BR><BR>Yes, that&#039s easy.<BR><BR>Let&#039s see...<BR><BR>&#060;%<BR>If fldA &#060;= fldB Then &#039 A B, but where is C<BR>&nbsp;&nbsp;&nbsp; If fldB &#060;= fldC Then<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; median = fldB &#039 order A B C<BR>&nbsp;&nbsp;&nbsp; ElseIf fldA &#060;= fldC Then<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; median = fldC &#039 order A C B<BR>&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; median = fldA &#039 order C A B<BR>&nbsp;&nbsp;&nbsp; End If<BR>Else &#039 B A, but where is C?<BR>&nbsp;&nbsp;&nbsp; If fldA &#060;= fldC Then<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; median = fldA &#039 order B A C<BR>&nbsp;&nbsp;&nbsp; ElseIf fldB &#060;= fldC Then<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; median = fldC &#039 order B C A<BR>&nbsp;&nbsp;&nbsp; Else <BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; median = fldB &#039 order C B A<BR>&nbsp;&nbsp;&nbsp; End If<BR>End If<BR>%&#062;<BR><BR>Is that what you said? Looks right to me...<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•