From: | "Oliveiros d'Azevedo Cristina" <oliveiros(dot)cristina(at)marktest(dot)pt> |
---|---|
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-07 11:04:53 |
Message-ID: | 0FD1E8C83BCC4801952A4DEDE3E9713E@marktestcr.marktest.pt |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Howdy, Tarsis.
Please try this out.
SELECT a.id, id_table1,a.name
FROM "Table2" a
NATURAL JOIN
(SELECT id_table1
"Table2"
GROUP BY id_table1
HAVING COUNT(*) > 1) b
Tell me if it worked or not, and if it didn't the errors/uncorrect results.
Best,
Oliveiros
----- Original Message -----
From: "Tarsis Lima" <tarsis(dot)lima(at)gmail(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Sent: Wednesday, January 05, 2011 2:18 PM
Subject: [SQL] return records with more than one occurrences
> 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 | Susanne Ebrecht | 2011-01-07 12:39:47 | Re: pattern matching with dates? |
Previous Message | Samuel Gendler | 2011-01-07 10:44:07 | Re: pattern matching with dates? |