You can use common table expression with JSON_QUERY() and json_table() as below:
Schema and insert statements:
create table attendance (EmpNo int,attn_date date);
insert into attendance values(2,DATE '2021-09-02');
insert into attendance values(3,DATE '2021-09-03');
Query:
with emp_json as
( SELECT JSON_QUERY('[{"EmpNo":"1", "Dept":1},{"EmpNo":"2", "Dept":1},{"EmpNo":"3", "Dept":2},{"EmpNo":"4", "Dept":2}]', '$' ) AS EmpDetails
FROM DUAL
)
SELECT emp.EmpNo , emp.Dept
FROM json_table( (select EmpDetails from emp_json) , '$[*]'
COLUMNS ( EmpNo PATH '$.EmpNo'
, Dept PATH '$.Dept'
)
)emp
inner join attendance att
ON att.EmpNo = emp.EmpNo
Output:
db<>fiddle here
For Oracle 11g you can use string manipulation to get your desired result.
Schema and insert statements:
create table attendance (EmpNo int,attn_date date);
insert into attendance values(2,DATE '2021-09-02');
insert into attendance values(3,DATE '2021-09-03');
Query:
with cte (emp_details) as
(
select regexp_substr(replace(replace(replace('[{"EmpNo":"1","Dept":1},{"EmpNo":"2","Dept":1},{"EmpNo":"3","Dept":2},{"EmpNo":"4","Dept":2}]','},{',';'),'[{',''),'}]','') ,'[^;]+', 1, level)
from dual
connect BY regexp_substr(replace(replace(replace('[{"EmpNo":"1","Dept":1},{"EmpNo":"2","Dept":1},{"EmpNo":"3","Dept":2},{"EmpNo":"4","Dept":2}]','},{',';'),'[{',''),'}]','') , '[^;]+', 1, level)
is not null
)
,
cte2 as
(
select regexp_replace(regexp_substr(emp_details, '[^,]+', 1, 1),'[^0-9]','') as EmpNo,
regexp_replace(regexp_substr(emp_details, '[^,]+', 1, 2),'[^0-9]','') as Dept
from cte
)
select emp.EmpNo,emp.Dept
from cte2 emp
inner join attendance att
ON att.EmpNo = emp.EmpNo
Output:
db<>fiddle here