create or replace function emp_count(
        search_date in date
)
    return number is res number := 0;
begin
    select count(*) into res from emp_work_ranges
        where search_date between
            employment_date and
            decode(dismissal_date,'',sysdate,dismissal_date);
    return res;
end;
/
