title: How to get average of values in T-SQL from specific table and join it's result with other one?
body: <p>So basically, I have two tables:</p>
  
  <ul>
  <li>STUDENT {IdStudent Int (PK), IndexNr Varchar(10), Year Int, Name Varchar(32), Surname Varchar(64)}</li>
  <li>MARK {IdMark Int (PK), IdStudent Int (FK), Value Int, Subject Varchar(32)}</li>
  </ul>
  
  <p>and as a first part of this exercise I need to run over them and grab all students from specific year (let's 2) and write out their average mark separately for each one of them.</p>
  
  <p>I wanted to do this through cursor but I'm having troubles with it.
  Mainly because I can't properly select these average marks using inner join.</p>
  
  <p>For example I would like to return IndexNr and AverageMark.</p>