Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Location
    Kalamazoo
    Posts
    42

    Wink Unanswered: Math functions in SQL!!!!!!!

    Hey all,
    I know this may sound silly but being a newbie I need your help on this one!!!
    I have a Q regarding using math functions in SQL. I have a table which has 4 colums namely: timestamp, kwh,kvarh and kvah.......Timestamp, kwh and kvarh have values in them and I want the kvah column to have values equal to kvah=SQRT(kwh*kwh+kvarh*kvarh).......Can anyone please lemme know how to do this using SQL.....I tried doing this in access(since the database is quite huge), but had some probs with network......So please help me out!
    TIA

  2. #2
    Join Date
    Nov 2002
    Posts
    207

    Re: Math functions in SQL!!!!!!!

    create table aa (timestamp, kwh int, kvarh int, kvah int);

    insert aa (kwh, kvarh, kvah) values(2, 3, 9);

    select * from aa;
    timestamp kwh kvarh kvah
    -------------------- ----------- ----------- -----------
    0x00000001007f5ac0 2 3 9

    update aa set kvah = sqrt(power(kwh,2)+power(kvarh,2));

    select * from aa;
    timestamp kwh kvarh kvah
    -------------------- ----------- ----------- -----------
    0x00000001007f5adc 2 3 3

    select sqrt(power(kwh,2)+power(kvarh,2)) from aa;
    --This is in float format
    --------------------
    3.605551

Posting Permissions

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