pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Jodi Kanter <jkanter@virginia.edu>
To: Postgres SQL List <pgsql-sql@postgresql.org>
Subject: Re: query assistance
Date: Tue, 4 Nov 2003 15:43:35 +0000
Message-ID: <200311041543.35899.dev@archonet.com> (raw)
In-Reply-To: <3FA7C2CE.4000902@virginia.edu>
References: <3FA7C2CE.4000902@virginia.edu>

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



view thread (7+ messages)  latest in thread

Message-ID: <200311041543.35899.dev@archonet.com>
Permalink:  ../200311041543.35899.dev@archonet.com/
Also on:    postgresql.org/message-id/200311041543.35899.dev@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, jkanter@virginia.edu
  Subject: Re: query assistance
  In-Reply-To: <200311041543.35899.dev@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox