New answers tagged

1

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: SUM ( CASE when lunch = 1 then round(Cast (( JulianDay(clock_out) - JulianDay(...


1

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. SELECT x.name, x.database_id, x.create_date, x.diff, CASE WHEN x.diff >= -50 AND x.diff < 0 THEN '-50+' WHEN x.diff >= 0 AND x.diff < 50 THEN '0+' ...


Top 50 recent answers are included