From: inungh on
I would like have a query or method to get most close value like
following:


Code Value

A+ 95
A 90
A- 85


I would like to have the query return A+ if value is greater or equals
than 95 and return A when the value between 90 and 95.


Is it possible to have a query or any function to return most close
value code?

Your information is great appreciated,

From: scubadiver on

Give this a go

expr1: IIF([value]>=95, "A+",IIF(90=<[value]<95,"A","A-"))



"inungh" wrote:

> I would like have a query or method to get most close value like
> following:
>
>
> Code Value
>
> A+ 95
> A 90
> A- 85
>
>
> I would like to have the query return A+ if value is greater or equals
> than 95 and return A when the value between 90 and 95.
>
>
> Is it possible to have a query or any function to return most close
> value code?
>
> Your information is great appreciated,
>
>
From: louisjohnphillips on
On Jul 4, 8:34 am, inungh <inu...(a)gmail.com> wrote:
> I would like have a query or method to get most close value like
> following:
>
> Code       Value
>
>   A+         95
>   A           90
>   A-          85
>
> I would like to have the query return A+ if value is greater or equals
> than 95 and return A when the value between 90 and 95.
>
> Is it possible to have a query or any function to return most close
> value code?
>
> Your information is great appreciated,

For completeness, please test this algorithm

select iif( value >= 95, 'A+',
iif( value >= 90, 'A',
iif( value >=85, 'A-', 'Unrated' ))) as Code
from MyGradeTable;

It should test for values 95 and above and assign those an 'A+'.
Failing to find a value of 95 and above, it should go on to the next
test of 90 and above. Failing to find a value of 90 and above, it
should test for 85 and above. If the value does not meet any of the
criteria, the code of 'Unrated' will be assigned.
From: inungh on
On Jul 4, 11:52 am, scubadiver <scubadi...(a)discussions.microsoft.com>
wrote:
> Give this a go
>
> expr1: IIF([value]>=95, "A+",IIF(90=<[value]<95,"A","A-"))
>
>
>
> "inungh" wrote:
> > I would like have a query or method to get most close value like
> > following:
>
> > Code       Value
>
> >   A+         95
> >   A           90
> >   A-          85
>
> > I would like to have the query return A+ if value is greater or equals
> > than 95 and return A when the value between 90 and 95.
>
> > Is it possible to have a query or any function to return most close
> > value code?
>
> > Your information is great appreciated,- Hide quoted text -
>
> - Show quoted text -

Thanks for the message,
I just need continue to add for B+, B, B-, C+....etc.
am I right?

Thanks again,
From: louisjohnphillips on
On Jul 4, 9:00 am, inungh <inu...(a)gmail.com> wrote:
> On Jul 4, 11:52 am, scubadiver <scubadi...(a)discussions.microsoft.com>
> wrote:
>
>
>
>
>
> > Give this a go
>
> > expr1: IIF([value]>=95, "A+",IIF(90=<[value]<95,"A","A-"))
>
> > "inungh" wrote:
> > > I would like have a query or method to get most close value like
> > > following:
>
> > > Code       Value
>
> > >   A+         95
> > >   A           90
> > >   A-          85
>
> > > I would like to have the query return A+ if value is greater or equals
> > > than 95 and return A when the value between 90 and 95.
>
> > > Is it possible to have a query or any function to return most close
> > > value code?
>
> > > Your information is great appreciated,- Hide quoted text -
>
> > - Show quoted text -
>
> Thanks for the message,
> I just need continue to add  for B+, B, B-, C+....etc.
> am I right?
>
> Thanks again,- Hide quoted text -
>
> - Show quoted text -

Yes. I'm not sure how far the iif can be nested, but I expect you
will not grade below 'F-'.