From: | Russell Galyon <russellgalyon(at)gmail(dot)com> |
---|---|
To: | Tarsis Lima <tarsis(dot)lima(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: return records with more than one occurrences |
Date: | 2011-01-08 04:48:17 |
Message-ID: | AANLkTi=DkWUsuG979oCQK6O1BuhNox4zjqpKGfLL-CjP@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
SELECT
t.id
t.id_table1
t.name
FROM
Table2 t
INNER JOIN
(SELECT
t_inner.id_table1
FROM
Table2 t_inner
GROUP BY 1
HAVING COUNT(*) > 1) temp
ON temp.id_table1 = t.id_table1
;
On Wed, Jan 5, 2011 at 8:18 AM, Tarsis Lima <tarsis(dot)lima(at)gmail(dot)com> wrote:
> how would the SELECT to return only records with more than one
> occurrences of id_table1? example:
> -- Table1
> -- id --
> -------------------------
> 1
> 2
>
>
> -- Table2
> id --- | id_table1 | name
> ----------------------------------------------
> 4 ---- | ----- 1 ------ | Tom
> 5 ---- | ----- 1 ------ | Luci
> 6 ---- | ----- 2 ------ | Cleber ------>this can not return
>
>
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
From | Date | Subject | |
---|---|---|---|
Next Message | Jasen Betts | 2011-01-08 10:22:23 | Re: pattern matching with dates? |
Previous Message | Richard Huxton | 2011-01-07 16:09:50 | Re: pattern matching with dates? |