-- Collection of code snippets by Arne Vajhøj 
-- (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
CREATE TABLE studentkompetencer (
   cpr INTEGER,
   studyline VARCHAR2(10),
   kompetencenavn VARCHAR2(20),
   PRIMARY KEY(cpr,kompetencenavn)
);

INSERT INTO studentkompetencer VALUES (21,'swu','mat A');
INSERT INTO studentkompetencer VALUES (21,'swu','mat B');
INSERT INTO studentkompetencer VALUES (22,'ba','his A');

CREATE TABLE studieelementkompetencer (
   name VARCHAR2(10),
   kompetencenavn VARCHAR2(20),
   PRIMARY KEY(name,kompetencenavn)
);

INSERT INTO studieelementkompetencer VALUES ('swu','mat A');
INSERT INTO studieelementkompetencer VALUES ('swu','mat B');
INSERT INTO studieelementkompetencer VALUES ('ba','his A');
INSERT INTO studieelementkompetencer VALUES ('ba','mus C');

(SELECT DISTINCT studentkompetencer.cpr,studieelementkompetencer.kompetencenavn
FROM studentkompetencer JOIN studieelementkompetencer
ON studentkompetencer.studyline=studieelementkompetencer.name)
MINUS
(SELECT cpr,kompetencenavn
FROM studentkompetencer);
