title: sql Row_Number function is not working after created in table
body: <p>I hope this isn't a repeated discussion.  I did search through the forums and didn't find anything that related to my problem.  I love this site by the way. It has helped me for a couple years now and I usually will get all my questions solved by searching this site.</p>
  
  <p>Anyway, I am running into an issue in SQL with the ROW_NUMBER() function.  I created a view that involves joining a different view and a table and in the view I pulled fields from both the view and the table, but I also created two fields that was a  ROW_Number() field called seq_number and another field called seq_alpha.  </p>
  
  <p>Seq Number field is:</p>
  
  <p>ROW_NUMBER() over(order by book_date, room, start) as seq_number,</p>
  
  <p>The seq_alpha field is a case field that is based on what the row number is to give an alpha letter instead.</p>
  
  <p>For example </p>
  
  <p>case ROW_NUMBER() over(order by book_date, Room, Start)
  when 1 then 'A'
  when 2 then 'B'
  when 3 then 'C'
  ....
  End as seq_alpha</p>
  
  <p>When I created the view for testing purposes I used a WHERE clause and everything worked exactly the way it should.  I then commented out the Where clause and had the table created.</p>
  
  <p>Then after the view was created I tried to pull the created view and used the same Where clause that worked when creating the view but now did it like:</p>
  
  <p>select *
  from created_view
  where (same as I used for testing)</p>
  
  <p>But now what happens is the seq_number field looks at the entire view instead of letting the where clause filter out the results.  All the other data pulls correctly, but the seq_number and seq_alpha fields don't.  So instead of having the seq number be 1-22 in my 22 results it is 400,000 range and the seq_alpha field doesn't even display anything because I only went up to 51 in my case.</p>
  
  <p>Has anyone had similar issues with trying to pull a row_number field after it is created and the field not filtering the results with the where clause?</p>
  
  <p>Thanks for your help in advance!</p>
  
  <p><strong>EDIT</strong>
  After Mikael's response it seems unlikely that I am able to create a row_number field in a view and then query the view afterward and have it work the way I want.  So, my next question is is there a way to create an alpha sequence based on the row number that I can put in a view and be able to query later and be able to have it work correct based on the where clause?  Or do I just need to create the alpha sequence field every time I would pull this view?</p>
  
  <p>J</p>