calculate a complex field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nafise
    New Member
    • Oct 2007
    • 1

    calculate a complex field

    Hi,
    I have a problem in calculating a field in a table.
    I have 2 tables with these fields:
    1- examcode , p1, p2, P
    2- examcode, f1, f2

    I want to update the first table to calculate the value of "P" field. It is a bit complex, because I want it to be calculated like :
    P= (p1 * f1 + p2 * f2) / (f1 + f2) if p1 <> -1 and p2 <> -1 ( if any of these two is -1 it should be omitted from the formula) (p1 , f1 and p2, f2 are the correspond fields from the two tables )
    (off course there are other fields in these tables and I can't put them in one table)

    I'll be glad if anyone could help me,
    thanks
  • epots9
    Recognized Expert Top Contributor
    • May 2007
    • 1352

    #2
    Originally posted by nafise
    Hi,
    I have a problem in calculating a field in a table.
    I have 2 tables with these fields:
    1- examcode , p1, p2, P
    2- examcode, f1, f2

    I want to update the first table to calculate the value of "P" field. It is a bit complex, because I want it to be calculated like :
    P= (p1 * f1 + p2 * f2) / (f1 + f2) if p1 <> -1 and p2 <> -1 ( if any of these two is -1 it should be omitted from the formula) (p1 , f1 and p2, f2 are the correspond fields from the two tables )
    (off course there are other fields in these tables and I can't put them in one table)

    I'll be glad if anyone could help me,
    thanks
    lets get this straight,first you:

    get the data p1, p2, f1, f2 from the database
    check to make sure that p1 and/or p2 doesn't equal -1
    if they do
    ???
    if they don't
    P= (p1 * f1 + p2 * f2) / (f1 + f2)
    then update the table field

    is this correct?

    Comment

    Working...