Tema: Sentencia
Ver Mensaje Individual
  #4 (permalink)  
Antiguo 24/02/2013, 07:47
Ueki
 
Fecha de Ingreso: septiembre-2009
Mensajes: 210
Antigüedad: 14 años, 8 meses
Puntos: 19
Respuesta: Sentencia

Suponiendo que tus campos son:
- Código plato (idPla)
- Nombre plato (nomPla)

Podrías hacer el siguiente select en la tabla PLATOS:
Código SQL:
Ver original
  1. WITH CONTAR_PLATOS AS (
  2.     SELECT COUNT(idPla) AS "Platos", nomPla FROM PLATOS GROUP BY nomPla
  3.     ),
  4. MAX_PLATOS AS (
  5.     SELECT MAX("Platos") AS "Maximo" FROM CONTAR_PLATOS
  6.     )
  7. SELECT nomPla, "Platos" FROM CONTAR_PLATOS WHERE "Platos" = (SELECT "Maximo" FROM MAX_PLATOS);