I have this query to update another table but getting error.
With CTE AS
(Select employer_id, employee_id, start_date, end_date, hourly_rate, end_date - start_date AS time_worked
FROM payroll_timesheet)
INSERT INTO payroll_timelog
SELECT * FROM CTE
WHERE employee_id = 1;
I get this error:
ERROR: column "employee_id" is of type integer but expression is of type timestamp with time zone
LINE 5: SELECT employer_id, employee_id, start_date, end_date, hourl...
^
HINT: You will need to rewrite or cast the expression.
It seems to be mapping employee_id with start_date.
Or is there a syntax error in the query?