Having count

10/11/2006 - 09:24 por marcwentink | Informe spam
Aqui tengo una relation de 1:1 Organization - Profile. Pero cuando hago
lo siguente hay doblas que quiero borrar. Son errores.

Select org.name, org.relationnumber, prof.id
from organizations org left join profiles prof
on prof.id_organization = org.id
where prof.id is not null order by org.name

Puedo leer todo el resultato, pero no hay una manera como puedo ver
solo las reglas doblas? Algo como:

Select org.name, org.relationnumber, prof.id
from organizations org left join profiles prof
on prof.id_organization = org.id
where prof.id is not null and having count(*) > 1


quizas?

Preguntas similare

Leer las respuestas

#1 Javier Loria
10/11/2006 - 14:14 | Informe spam
Hola:
Algo como:
SELECT org.name
, org.relationnumber
, prof.id
FROM organizations org
LEFT JOI profiles prof
ON prof.id_organization = org.id
WHERE prof.id is not null
GROUP BY org.name, org.relationnumber, prof.id
HAVING count(*) > 1
Saludos,

Javier Loria
Costa Rica-MVP
Solid Quality Learning

wrote in message
news:
Aqui tengo una relation de 1:1 Organization - Profile. Pero cuando hago
lo siguente hay doblas que quiero borrar. Son errores.

Select org.name, org.relationnumber, prof.id
from organizations org left join profiles prof
on prof.id_organization = org.id
where prof.id is not null order by org.name

Puedo leer todo el resultato, pero no hay una manera como puedo ver
solo las reglas doblas? Algo como:

Select org.name, org.relationnumber, prof.id
from organizations org left join profiles prof
on prof.id_organization = org.id
where prof.id is not null and having count(*) > 1


quizas?

Respuesta Responder a este mensaje
#2 marcwentink
12/11/2006 - 08:31 | Informe spam
Javier Loria schreef:

Hola:
Algo como:
> SELECT org.name
, org.relationnumber
, prof.id
FROM organizations org
LEFT JOI profiles prof
ON prof.id_organization = org.id
WHERE prof.id is not null
GROUP BY org.name, org.relationnumber, prof.id
HAVING count(*) > 1



Eso es el correcto query cuando yo leo que he escrito, pero my problema
es que hay profiles doblas que no son valido, entonce quiero ver las
doblas como eso:


"Empressa A", 3242, 1234
"Empressa A", 3242, 5678

Y despues borrar el profile con el numero 5678

y no como:

"Empressa A", 3242, 1234
"Empressa A", 3242, 1234

y count(org.name, org.relationnumber) no es valido. Entonces siguo
buscando :-)

Pero muchas gracias por tu ayuda!!

Marcus Wentink
Respuesta Responder a este mensaje
#3 marcwentink
28/11/2006 - 11:08 | Informe spam
Eso es lo que busce' :

SELECT org.name, org.relationnumber

FROM organizations org
LEFT JOIn profiles prof
ON prof.id_organization = org.id
WHERE prof.id is not null
GROUP BY org.name, org.relationnumber
HAVING count(*) > 1

Marc Wentink
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida