I'm having a problem with this query. I want to make an operation for my payroll system. I Here is my query which doesn't work.
Query:
select
hrrawd_timein,
hrrawd_shiftin,
(
(extract(hour from (hrrawd_timein::time))
- extract(hour from (hrrawd_shiftin::time))
)::numeric
) AS shiftinhours,
(
(extract(minute from (hrrawd_timein::time))
- extract(minute from (hrrawd_shiftin::time))
)::numeric
) AS shiftinminutes,
(
((extract(hour from (hrrawd_timein::time))
- extract(hour from (hrrawd_shiftin::time)
))*60)::numeric
)
+
(
(extract(minute from (hrrawd_timein::time))
- extract(minute from (hrrawd_shiftin::time))
)::numeric
) AS Total,
case
when (Total >0) then 'Late'
else 'EARLY'
end as remarks
FROM hr.hrrawd;
Error:
> ERROR: column "total" does not exist LINE 7: case when (Total >0)
> then 'Late'