I have a table with container numbers and a completed_on date field with a timestamp. It also have the vessel id, and crane id. I need to count the amount of completed containers and not completed, by asking if the completed_on is null or not.
I’ve written something like this, but it doesn’t work.
select vessel,
crane_no,
count(container_no) tot_moves,
case when completed_on is null then count(container_no) end as pending,
case when completed_on is not null then count(container_no) end as completed,
min(completed_on) first_m,
max(completed_on) last_m
from
containers
group by vessel, crane_no, completed_on
Any ideas?
put the count() around the cases.