Fix sql issue and work on calculation page