title: Getting syntax error using the Lead/Lag function in SQL Server 2012
body: <p>I'm new to using the Lead/Lag function in SQL Server 2012 and I got the syntax error when I tested it in SQL Server Management Studio. I used the lead and lag function for the purpose of fetching previous and next row values.</p>
  
  <p>SQL Syntax I used:</p>
  
  <pre><code>SELECT 
      Id, Name, Address, Age, Nationality,
      LEAD(Name, 1) OVER (ORDER BY Id ) LeadValue,
      LAG(Name, 1) OVER (ORDER BY Id ) LagValue
  FROM 
      Table
  </code></pre>
  
  <p>Error message:</p>
  
  <blockquote>
    <p>Msg 156, Level 15, State 1, Line 4<br>
    Incorrect syntax near the keyword 'Table'.</p>
  </blockquote>
  
  <p>Please advise what I've missed here. Thanks</p>