sql - Why is my query failing upon adding SUM function? -
sql - Why is my query failing upon adding SUM function? -
the next query executes expected, giving me expected output given fields beingness queried
select 1 seq, term_desc term, primary_college_desc college, level_grouping_code level_code, level_grouping_desc level_desc secopy se
however, when add together function sum() on field, i'm getting next error regarding term_desc, isn't related id_count, sum() function used on.
select 1 seq, term_desc term, primary_college_desc college, level_grouping_code level_code, level_grouping_desc level_desc, sum(id_count) headcount secopy se
i'm getting next error:
column 'student_enrollment_copy.term_desc' invalid in select list because not contained in either aggregate function or grouping clause.
why fail after adding sum() function?
alias name table not needed you should utilize columns in grouping clause except aggregate function select 1 seq, term_desc term, primary_college_desc college, level_grouping_code level_code, sum(id_count) headcount secopy grouping term_desc,primary_college_desc,level_grouping_code
sql sql-server sql-server-2008
Comments
Post a Comment