Link to home
Create AccountLog in
Avatar of Warfarin162
Warfarin162

asked on

SQL - creating a formula

I am trying to make the following formula work in SQL 2008:

MAC = (#Combine.Sevo_out)/(1.8*10^(-0.00269(#Combine.Age - 40)))

I get an error that I assume is related to the "^", but I am not sure how to fix this....

Thanks!
Avatar of volking
volking

Look up POWER in Sql help
ASKER CERTIFIED SOLUTION
Avatar of Armand G
Armand G
Flag of New Zealand image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Warfarin162

ASKER

I am getting

incorrect syntax near '(' .

It appears the issue is somewhere in the Power section of the equation.  Here is the final code (that runs without the new line without issue:

SELECT #Combine.PatientID
      ,      #Combine.CaseNm
      ,      #Combine.Age
      ,      #Combine.Date_Time
      ,      #Combine.SpO2
      ,      #Combine.HR
      ,      #Combine.Pulse
      ,      #Combine.EtCO2
      ,      #Combine.RR
      ,      #Combine.Temp
      ,      #Combine.NISBP
      ,      #Combine.NIDBP
      ,      #Combine.NIMean
      ,      #Combine.InvSBP
      ,      #Combine.InvDBP
      ,      #Combine.InvMean
      ,      #Combine.InvSBP2
      ,      #Combine.InvDBP2
      ,      #Combine.InvMean2
      ,      #Combine.FiO2
      ,      #Combine.Sevo_In
      ,      #Combine.Sevo_Out
      ,      (#Combine.Sevo_out)/(1.8*POWER(10,(-0.00269(#Combine.Age - 40)))) as MACsevo
      ,      #Combine.Des_In
      ,      #Combine.Des_Out
      ,      #Combine.Iso_In
      ,      #Combine.Iso_Out
      ,      #Combine.N2O_In
      ,      #Combine.N2O_Out
      ,      #Combine.CVP
      ,      #Combine.BIS
      ,      #Combine.BIS_SQI
FROM #Combine
try removing

 as MACsevo

Sorry dumb comment before ...
your missing an arithmetic operator here

 (#Combine.Sevo_out)/(1.8*POWER(10,(-0.00269     here         (#Combine.Age - 40))))
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
I think this is working... trying to resolve the error from "dividing by zero" when patients are 40 years old, but after I fix that I will award points :)