using multiple "IF Then"'s in a Querry.

  • Thread starter Thread starter Mario
  • Start date Start date
M

Mario

Let's say I have a table like this

Name |Maths |Science |English
-------------------------------
David |45 |65 |43
Mathew |78 |87 |67
Tom |56 |73 |74
Jeena |34 |91 |98

I want to calculate the grade, by creating a querry whose
output looks like this.

Name |Maths |Science |English |Grade
----------------------------------------
David |45 |65 |43 |
Mathew |78 |87 |67 |
Tom |56 |73 |74 |
Jeena |34 |91 |98 |

Grade will be calculated using the rules

A - Math >80 and Science >90 and English >70
B - Math >70 and Science >80 and English >60
C - Math >60 and Science >70 and English >50

Can any body help me with the above querry
 
Try this: when using the IIf expression it can be used
within an expression. Your if is: expression, true value,
false value. You can insert an IIf expression where the
false value lies.

IIf Math>80, A , IIf Math>70, B, IIf Math>60, C, IIf
Math>50,D, F

This says that if math is greater than 80, then the result
is A, If math is greater than 70 the result is B, If math
is greater than 60 the result is C, If math is greater
than 50 the result is D, and all other values (which will
be less than 50) are F.

Just insert the IIf expression for the false value until
you come to the end of expression. Do this for Science and
so on. Let me know if this helps.
 
Thank you very much.

It worked.
-----Original Message-----
Try this: when using the IIf expression it can be used
within an expression. Your if is: expression, true value,
false value. You can insert an IIf expression where the
false value lies.

IIf Math>80, A , IIf Math>70, B, IIf Math>60, C, IIf
Math>50,D, F

This says that if math is greater than 80, then the result
is A, If math is greater than 70 the result is B, If math
is greater than 60 the result is C, If math is greater
than 50 the result is D, and all other values (which will
be less than 50) are F.

Just insert the IIf expression for the false value until
you come to the end of expression. Do this for Science and
so on. Let me know if this helps.





.
 
Back
Top