Distinct combination with SQL
  (2-replies, Power system - SQL (general/non-embedded))
Post your reply | Return to Forum  Refresh | ascending | descending
Author: Captndjc Return to Forum  Refresh 2010-07-22 09.20.01
Thanks Muehe

I got stuck on "a.user = b.user and a.resp <> b.resp" and couldn't see just 
using just less than. Must have been to many trees......
Author: Muehe Return to Forum  Refresh 2010-07-21 16.24.58
select a.user, a.resp, b.resp
from mylib.myfield a
join mylib.myfield b
on a.user = b.user and a.resp < b.resp
Author: Captndjc Return to Forum  Refresh 2010-07-21 16.02.47
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.  
Your reply | top | Return to Forum | ascending | descending
      Name:
    
By pressing you agree to the
forum guidelines
      Note: Your message is limited to 3500 characters.