Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Users Not Assigned to a Group

Status
Not open for further replies.

asmall

Programmer
Dec 26, 2002
31
0
0
US
I have a list of users that are assigned or not assigned to a group. A user can be assigned to multiple groups.
I am trying to write a query that would show me the groups they are assigned to as well as the groups they are not.
Having trouble with the logic and wondering if anyone could provide some assistance.

See attachment for an example on what I am attempting to accomplish.
 
 http://files.engineering.com/getfile.aspx?folder=08ca103b-d84b-466a-b429-c4edb9801344&file=Groups_Example.docx
untested - it's easier in Oracle due to the Oracle MINUS command.

select a.user, ' in ', a.group from groups_table a -- these are "in"
union
select b.user, ' not in ', b.group from groups_table b
where b.group not in ( -- these are the "not in"
select distinct (c.group) from groups_table c -- these are "in"
where b.user = c.user)



==================================
advanced cognitive capabilities and other marketing buzzwords explained with sarcastic simplicity


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top