From: | "jose' soares" <sferac(at)bo(dot)nettuno(dot)it> |
---|---|
To: | pgsql-ayuda(at)tlali(dot)iztacala(dot)unam(dot)mx |
Subject: | Re: [pgsql-ayuda] Seleccionando registros |
Date: | 1999-02-04 13:38:28 |
Message-ID: | 36B9A2D4.C38280F5@bo.nettuno.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Adrian Galindo ha scritto:
> Hola lista. Aqui de regreso....
>
> Una pregunta tal vez medio obvia y novatona:
>
> Con distinct selecciono los registros sin duplicar, los repetidos no los
> regresa... como le hago para que solo me muestre los repetidos??
>
La tabla contiene los seguientes datos; y yo quiero saber quantos tienen lo
mismo apellido:
apellido |nombre
----------+-----------------
CANOVA |ROMANO
CHIUCHIOLO|GIULIANO
CHIUCHIOLO|ANNALISA
JOHANNEY |GEORGE
JOHANNEY |MARY
OWUSU |RICHARD
PREVITI |ENRICO
PREVITI |PATRIZIA
PREVITI |VALERIO
(9 rows)
select APELLIDO from FAMILIA group by APELLIDO having count (APELLIDO) > 1;
apellido
-------------------
CHIUCHIOLO
JOHANNEY
PREVITI
(3 rows)
En SQL92 se puede hacer asi:
select * from FAMILIA where APELLIDO in (
select APELLIDO from FAMILIA group by APELLIDO having count (APELLIDO) >
1;
);
pero PostgreSQL tiene un bug en HAVING por eso tienes de hacerlo en dos
fases:
- Jose' -
And behold, I tell you these things that ye may learn wisdom; that ye may
learn that when ye are in the service of your fellow beings ye are only
in the service of your God. - Mosiah 2:17 -
From | Date | Subject | |
---|---|---|---|
Next Message | Ricardo A. Moreno V. | 1999-02-04 16:43:22 | Re: [pgsql-ayuda] select |
Previous Message | Adrian Galindo | 1999-02-04 00:51:13 | [pgsql-ayuda] Seleccionando registros |