Fixed SQL code for writing daily status
Misc change