How can I write an SQL to come up with a distinct combination of values from a
single field? Our SOX requirement is to check for user responsibilities and
make sure that certain ones don't cross. The data base has a single record for
each user/responsibility.
User/responsibility
#1 A
#1 C
#1 D
#2 B
Responsibility A B C D
A X V V
B V X
C X V
D V V X
Thus X can not happen but V is a violation. Or in other words, user #1 is in
violation because they have responsibility A & D.
If I join the file to itself, I can come up with the combinations of (A,C)
(A,D) (C,A) (C,D) (D,A) and (D,C) for user #1. But in essence (A,D) and (D,A)
are the same. So the question becomes, what SQL will give the results of (A,C)
(A,D) and (C,D) only as the others are repeats? This metrics is very large and
I wanted to eliminate half of the possibilities to look at.
|