Tema: Consulta
Ver Mensaje Individual
  #4 (permalink)  
Antiguo 27/04/2010, 07:43
Avatar de webness
webness
 
Fecha de Ingreso: enero-2009
Ubicación: BOGOTA
Mensajes: 312
Antigüedad: 15 años, 3 meses
Puntos: 5
Respuesta: Consulta

Hola que pena contigo mi error, acabe de hacerlo en postgres y ya lo tengo:
Código SQL:
Ver original
  1. SELECT  m.nombre AS ciudad,
  2.         (SELECT COUNT(v.id) FROM vivienda  v WHERE   m.id = v.municipio) AS total_vivienda,
  3.         (SELECT COUNT(h.id) FROM habitante h,vivienda v WHERE   v.id =   h.vivienda AND v.municipio = m.id) AS total_habitantes
  4. FROM    municipio m