You are here: Re: SQL question « MsSQL Server « IT news, forums, messages
Re: SQL question

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация