Hi I have the following code:(SELECT --use the row_number function to get the newest record ROW_NUMBER() OVER(PARTITION BY s.SpecRecordID_rc ORDER BY s.SpecIssueNo DESC) AS seqFROM dbo.mp_RPINSpecifications s (NOLOCK))SELECT s.SpecRecordID_rc, s.SpecIssueNo, s.SpecpacksPerMinute, r.RecordID, r.Resource, s.SpecIDFROM dbo.mp_RPINSpecifications s (NOLOCK)INNER JOIN mp_rcResourceData r (NOLOCK) ON s.SpecRecordID_rc = r.RecordIDWHERE seq = 1 --filter for the newest record onlyORDER BY r.Resource, s.SpecIssueNo
I am trying to get the most recent s.SpecIssueNo for each Resource, if I run the code inside the brackets I can see the seq col being filled correctly but when I run the full query i am getting this error message: Msg 207, Level 16, State 1, Line 21Invalid column name 'seq'.Any ideas to help me would be great.