Ver Mensaje Individual
  #2 (permalink)  
Antiguo 04/05/2012, 13:38
alexg88
 
Fecha de Ingreso: abril-2011
Mensajes: 1.342
Antigüedad: 13 años, 8 meses
Puntos: 344
Respuesta: Consulta sobre consultas

Aunque parece una consulta fácil, no es tan sencillo implementarla.

Te dejo una posible forma:

Código SQL:
Ver original
  1. SELECT city
  2. FROM (SELECT COUNT(*) AS total, city  
  3. FROM br_user
  4. GROUP BY city) AS temp INNER JOIN
  5. (SELECT MAX(total) AS maximo
  6. FROM
  7. (SELECT COUNT(*) AS total, city  
  8. FROM br_user
  9. GROUP BY city) AS temp2) AS temp3
  10. ON temp3.maximo = temp.total

o así

Código SQL:
Ver original
  1. SELECT city
  2. FROM
  3. (SELECT COUNT(*) AS total, city  
  4. FROM br_user
  5. GROUP BY city) AS temp
  6. WHERE total =
  7. (SELECT MAX(total) AS maximo
  8. FROM
  9. (SELECT COUNT(*) AS total, city  
  10. FROM br_user
  11. GROUP BY city) AS temp2)