I have varchar type column in my sql table(SQL 2008) for storing student marks. If I store only the marks I can calculate the sum of marks by casting the column to integer.
But I need to store Absent for absentees. And now, its showing error in that Absent when casting to integer and sum the value, after inserting Absent.
Is it possible to sum only the marks, and excluding the Absent?I tried like this
select sum(cast(Marks as integer))
from Results
group by Marks
No need to add
Group byClause.No other columns in Select other than column used in Aggregate function then no need to have GROUP BY.