title: Can I calculate regression slope in sql?
body: <p><a href="https://i.stack.imgur.com/VKgm1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VKgm1.png" alt="enter image description here"></a></p>
  
  <p>I have a table like this, NA = NULL value in the table.
  I wonder if I could calculate the regression slope for each of the policy.
  The formula is as follow<a href="https://i.stack.imgur.com/E2LiZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E2LiZ.png" alt="enter image description here"></a>
  X is the years(2009-2014)
  Y is the rate in the table.
  For policy 2, I would like to ignore the year with null value and calculate the slope for each of the following year.
  IS it possible to do this? Thank you.</p>
  
  <p>[EDIT]
  My expected result is as follow,
  <a href="https://i.stack.imgur.com/NlcoY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NlcoY.png" alt="enter image description here"></a></p>