SQL - change calculated result depending on value in another column
<p>I have a percentage column that I calculate based on two other columns. However, depending on the value in another column I would to be able to change that calculation.</p>

<p>For example</p>

<pre><code>server  outage  starttime         endtime           outage_seconds percentage
a       0       01/11/2015 09:14  01/11/2015 09:08  360            99.58334
b       0       01/11/2015 03:57  01/11/2015 03:34  1393           98.38774
c       1       01/11/2015 03:47  01/11/2015 03:29  1050           98.78473
d       0       01/11/2015 03:47  01/11/2015 03:29  1086           98.74306
e       1       01/11/2015 03:47  01/11/2015 03:29  1056           98.77778
</code></pre>

<p>Where the data in the outage column says 0 I want the percentage column to say 100%</p>

<p>My code is </p>

<pre><code>SELECT [server]
  ,[outage]
  ,[starttime]
  ,[endtime]
  ,[outage_seconds] = datediff(second, 0, cast((endime - starttime)as time))
  ,[percentage] = 100-(datediff(second, 0, cast((endtime - starttime)as float))/86400.0)*100
FROM [availability_outages].[dbo].[pnet02_view]
</code></pre>