Invalid column name error showing up in query inside a stored procedure

2 thread on same question.