Re: query assistance

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: query assistance
Дата
Msg-id 200311041543.35899.dev@archonet.com
обсуждение исходный текст
Ответ на query assistance  (Jodi Kanter <jkanter@virginia.edu>)
Список pgsql-sql
On Tuesday 04 November 2003 15:16, Jodi Kanter wrote:
> Is there a straight forward way to pull out duplicates in a particular
> field given a value in another field?
> For example, I have a table that lists users and study names associated
> with those users. Each user can have one or more study names. My goal is
> to determine if any of these people have duplicate study names. There
> are duplicated study names across the system and that is ok. I just want
> to see if any users have duplicate study names among their studies.

Something like:

SELECT created_by, study_name, count(sty_pk)
FROM study
GROUP BY created_by, study_name
HAVING count(sty_pk) > 1;

--  Richard Huxton Archonet Ltd


В списке pgsql-sql по дате отправления:

Предыдущее
От: Paul Ganainm
Дата:
Сообщение: Re: Using UNION inside a cursor
Следующее
От: "Freshman"
Дата:
Сообщение: Please help me to slove this SQL statements