This works fine, except in the results, I don't want the rows where STILL_REQUIRED is 0.
I am using firebird.
Select ID, JobID, NAME, ORDERNUM, STARTAFTER, FINISHBEFORE,
START_OFFSET_MINS,
TOTAL_MINUTES_REQ -
(SELECT coalesce(SUM(TABLE_PROCESSTIMES.END_TIME-TABLE_PROCESSTIMES.START_TIME) / 60, 0)
FROM TABLE_PROCESSTIMES
WHERE TABLE_PROCESSTIMES.PROCESSID = TABLE_PROCESSES.ID AND TABLE_PROCESSTIMES.START_DATE <= '24.04.2018'
) AS STILL_REQUIRED
FROM TABLE_PROCESSES
ORDER BY JOBID, ORDERNUM;
STILL_REQUIRED
column code in theWHERE
clause, with!=0
after...HAVING still_required != 0
beforeORDER BY
.