You can't reference a column alias within the same SELECT clause as it was created in. In other words sum("total_time") is referencing something that doesn't exist yet. You'll either need to copy your previous CASE statement into your SUM() function call like this:
CASE when lunch = 1 then round(Cast (( JulianDay(clock_out) - JulianDay(...
This is probably the easiest way. You could also use a Common Table Expression, but it would make no real difference; it's a matter of style preference.
WHEN x.diff >= -50 AND x.diff < 0 THEN '-50+'
WHEN x.diff >= 0 AND x.diff < 50 THEN '0+'