sql code cleanup
sql for calculating residuals based on Manhattan totals