I have two bit type columns in my sql table, and the values in it are like,
FirstHalfLeave SecondHalfLeave
------------ -------------
0 1
1 1
I need to sum these two fields to make it leave for a single day and I need to dislay the exact result(3/2=1.5)
I just converted these bit to integer like
sum(CAST(StaffAttendance.FirstHalfStatus as Integer) +
CAST(StaffAttendance.SecondHalfStatus as integer))/2 as TotalLeave
it showing the result as 1 not 1.5, for this I think I need to cast it to double or to float, I dunno how to do this, can anyone help me here, thanks in advance
use
/2.0instead to force decimal typeEdit:
To remove the trailing zeros cast to
float. And I think you placed a)wrong. Try: