Oracle SQL. How to select specific IDs where value of columns specify criteria? -
i have following statement/query:
select table1.file_id, table1.status, table2.status table1 inner join table2 on table1.file_id = table2.file_id;
the result follows:
file id | status table 1 | status table 2 ----------------------------------------------------- 5500002 | ax | ics 5500002 | ax | icso 5500002 | axo | ics 5500003 | ax | ics 5500003 | ax | ics 5500003 | ax | ics 5500004 | null | icso test 5500004 | axo | ics 5500004 | ax | null
i need each file id check 4 statuses:
- ax - axo - ics - icso
i want run select on file id
s cover 4 statuses. can see file id
occurs multiple times , i'd want query return file id
fulfills requirement, in instance return 5500002 , 5500004.
for 5500004, there status mentions icso test
regardless of remainder of text if contain icso within cell, counts icso. same applies other statuses.
how go adding query select specific ids?
try below
select file_id ( select table1.file_id, table1.status status1, table2.status status2 table1 inner join table2 on table1.file_id = table2.file_id ) tab group file_id having count(distinct tab.status1) + count(distinct tab.status2) >= 4
Comments
Post a Comment