J Livingston SQL (3/10/2014)
maybe of some use
with cte_names as
SELECT StudentID, MAX(StudentName) AS StudentName
GROUP BY StudentID
, CAST ( AVG ( lcdscores.focus1 ) AS decimal ( 9 , 2 )) AS focus1
, CAST ( AVG ( lcdscores.cont1 ) AS decimal ( 9 , 2 )) AS controlling1
lcdscores INNER JOIN cte_names ON lcdscores.StudentID = cte_names.StudentID
GROUP BY lcdscores.StudentID
In the first sample data, there are a couple of NULL StudentID records. :-D
And the Excel Example is yet another set of data.
I refrained from writing a select statement, thinking that the poster would create one with AVG on a column.
And understand that the Group By creates the distinct records being asked for.
Hopefully they will understand a CTE.