title: Select stmt with ROW_NUMBER() OVER(PARTITION BY...) in Where clause
body: <p>I must be doing something wrong. I'm trying to use the row_number function to only select the values that have a rownum of <strong>1</strong>, so that I always get the latest <strong>index</strong>. However rownum is not recognized in the where-clause.</p>
  
  <pre><code>SELECT  fs.docu_id as docID 
  , fs.field_3 AS ProductNo
  , fs.field_4 AS [Status]
  , fs.field_5 AS [Index]
  ,pd.[doku_nr] AS docIDshort
  , ROW_NUMBER() OVER(PARTITION BY fs.field_3 ORDER BY fs.field_5 Desc) AS rownum
  FROM [table1] fs
  JOIN [table2] pd
  ON fs.docu_id=pd.docu_id 
  AND  fs.field_4 = 'valid'
  </code></pre>
  
  <p>What am I missing? Do I need to create a different select stmt?</p>
  
  <p>Thank you.</p>