Posted by --CELKO-- on 04/04/07 21:56
>> I have a table 'cust' as follows : <<
Please stop using silly, non-relational record numbering!! I am going
to assume that the impropery named columns are the key and that you
meant to post:
CREATE TABLE DeptAssignments
(emp_name CHAR(15) NOT NULL
REFERENCES Personnel (emp_name),
dept_name CHAR(1) NOT NULL
REFERENCES Departments(dept_name),
PRIMARY KEY (emp_name, dept_name));
>> Looking for SQL to output rows with (dept = b - no other rows with that name) OR (dept = a AND no other row for that name with dept = b) <<
SELECT emp_name
FROM DeptAssignments
GROUP BY emp_name
HAVING MIN(dept_name) = 'b' -- HAS ONE OR MORE B'S
OR (MIN(dept_name = 'a') AND MAX(dept_name = 'a'); -- A'S ONLY
[Back to original message]
|