TECHADVICE
asked on
Multiply two variables then divide by third variable in same table
Given the following Table
ID PERIOD DATA1 DATA2 DATA3
A 20071001 32 4 23
B 20071001 22 10 5
C 20071001 46 12 15
How can I run a select statement that would
DATA1*DATA2 = DATA4
DATA4/DATA3 = DATA5
All in the same select statement
Desired results would be:
ID PERIOD DATA4 DATA5
A 20071001 128 5.57
B 20071001 220 44.00
C 20071001 552 36.80
Also, I would need the statement to account for divide by zero issues.
ID PERIOD DATA1 DATA2 DATA3
A 20071001 32 4 23
B 20071001 22 10 5
C 20071001 46 12 15
How can I run a select statement that would
DATA1*DATA2 = DATA4
DATA4/DATA3 = DATA5
All in the same select statement
Desired results would be:
ID PERIOD DATA4 DATA5
A 20071001 128 5.57
B 20071001 220 44.00
C 20071001 552 36.80
Also, I would need the statement to account for divide by zero issues.
ASKER
is it possible to amend similar to the following:
select id, period, data1*data2 as data4, data4/data3 as data5
from yourtable
select id, period, data1*data2 as data4, data4/data3 as data5
from yourtable
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
from yourtable