Re: JavaDB / Apache Derby equivalent to the SQL Server IsNull, Oracle nvl and MySQL IfNull



This is the DB I'm looking at. (Many tables and columns excluded for
simplicity.)

TASK {taskid}
PROCESSTASK {runid, taskid, processid, startstamp, stopstamp}

I have a number of tables representing tasks that can be run multiple
times. Tasks are made up of one or more processes. The table I am
querying on records the start and stop times of the processes. The
purpose is to get the count of currently running processes.


select sc.scriptid, nvl((select count(pt.runid)
from processtask pt
where pt.runid = <RUN_ID>
and pt.stopstamp is null
group by pt.taskid), 0)
from task tk where tk.taskid in (<TASK_IDS>)

.