|
Posted by M A Srinivas on 04/05/07 06:41
On Apr 5, 2:56 am, "--CELKO--" <jcelko...@earthlink.net> wrote:
> >> 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
Your query does not provide the output (rec_id,name,dept) requested.
It is just listing name (emp_name)
Navigation:
[Reply to this message]
|