title: Oracle analytics: using LAG values in calculation?
body: <p>I have a table that records when tasks were completed. Tasks belong to a workflow, but in this example I'm just trying to get the LAG working.</p>
  
  <p>I would like to find information about how long each task takes.</p>
  
  <p>I've tried:</p>
  
  <pre><code>select
    completed_date,
    lag(completed_date) over (order by id) prevrow,
    prevrow - completed_date
  from
    task_complete
  where workflow_id = 1
  </code></pre>
  
  <p>But this results in an error.  Is there a way to calculate the difference between the current row and previous row?</p>