I am doing a migration from mysql to postgres, but there is a mistake, not much experience with postgres:
SELECT
SELECT m.* , (SELECT c.id
FROM corridas c
WHERE c.motoqueiro = m.id
AND (c.status = 0 OR c.status = 1)) as total
FROM motoqueiros m
WHERE now() - INTERVAL '17888 SECONDS' <= data_update
AND count(total) = 0;
Error message:
ERROR: column "total" does not exist LINE 2: ... INTERVAL '17888 SECONDS'