I want to select an exact subset from a table.
DDL to create table:
CREATE TABLE groups (group_id NUMBER, activity_id number);
INSERT INTO groups (group_id, activity_id) values (1,1);
INSERT INTO groups (group_id, activity_id) values (1,2);
INSERT INTO groups (group_id, activity_id) values (2,1);
INSERT INTO groups (group_id, activity_id) values (2,2);
INSERT INTO groups (group_id, activity_id) values (2,3);
INSERT INTO groups (group_id, activity_id) values (3,1);
INSERT INTO groups (group_id, activity_id) values (3,2);
INSERT INTO groups (group_id, activity_id) values (3,3);
INSERT INTO groups (group_id, activity_id) values (3,4);
If I want the group_id of activity_ids (1, 2 and 3), then I would like only the exact match for group_id 2 to return, not 1 and 3.
I can do this with LISTAGG but wanted to see if there was a cleaner solution or suggestions if I should structure my table differently.
group_id
values do you expect to have? Will you want subset/superset matching also? What about "partial matching"?