Hi,
My oracle database version : 11g
I am presenting the code here and these are the steps through which I created a table and within that theres a regular column with number but the 2nd column is a nested table.
1) create or replace type s_def_NT_DepEmployees is table of varchar2(100);
2)
create table employees_NT_test
( department_id number
, c_of_s_def_NT_DepEmployees s_def_NT_DepEmployees)
nested table c_of_s_def_NT_DepEmployees store as NTs_c_of_s_def_NT_DepEmployees
3) Now I have inserted 2 records:
insert into employees_NT_test values(1,s_def_NT_DepEmployees('Rahul','Myra'));
insert into employees_NT_test values(2,s_def_NT_DepEmployees('Rashi','Gaurav'));
4) Now firing this sql gives me employees of department_id : 1
select column_value
from table(select c_of_s_def_NT_DepEmployees from employees_NT_test where department_id = 1);
Output:
Rahul
Myra
Now my question : I just want to select the first subscript : ie: rahul(and not myra ) and it should be consistent such that if I select both departments I should get my output as:
Department_id | employees
1 | Rahul
2 | Rashi
PS: I am looking for an sql query, I hope I have presented my question clearly, if there are any doubts please let me know.
Thanks in advance
Rahul