Ver Mensaje Individual
  #8 (permalink)  
Antiguo 23/01/2015, 06:45
Avatar de gnzsoloyo
gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 5 meses
Puntos: 2658
Respuesta: no me da el resultado experado consulta mysql

Te dejo la solucion un poco más clara:

Código MySQL:
Ver original
  1. mysql> CREATE TABLE IF NOT EXISTS EMPREADO(
  2.     -> nombre VARCHAR(100) NOT NULL,
  3.     -> bonificacion INT UNSIGNED NOT NULL,
  4.     -> evento VARCHAR (50) NOT NULL);
  5. Query OK, 0 rows affected (0.01 sec)
  6.  
  7. mysql> INSERT INTO empreado
  8.     -> VALUES
  9.     -> (1, 'SAUL', 10, 'METAL'),
  10.     -> (2, 'ANA', 8, 'TURISMO'),
  11.     -> (3, 'ANDRES', 3, 'ALIMENTACION'),
  12.     -> (4, 'ANA', 5, 'ASESORAMIENTO');
  13. Query OK, 4 rows affected (0.00 sec)
  14. Records: 4  Duplicates: 0  Warnings: 0
  15.  
  16. mysql>
Código MySQL:
Ver original
  1. mysql> SELECT id, nombre, evento, MAX(bonificacion) bonificacion
  2.     -> FROM empreado
  3.     -> GROUP BY id, nombre, evento
  4.     -> ORDER BY 4 DESC;
  5. +----+--------+---------------+--------------+
  6. | id | nombre | evento        | bonificacion |
  7. +----+--------+---------------+--------------+
  8. |  1 | SAUL   | METAL         |           10 |
  9. |  2 | ANA    | TURISMO       |            8 |
  10. |  4 | ANA    | ASESORAMIENTO |            5 |
  11. |  3 | ANDRES | ALIMENTACION  |            3 |
  12. +----+--------+---------------+--------------+
  13. 4 rows in set (0.00 sec)
  14.  
  15. mysql>
  16. mysql> SELECT id, nombre, evento, MAX(bonificacion) bonificacion
  17.     -> FROM empreado
  18.     -> GROUP BY nombre
  19.     -> ORDER BY 4 DESC;
  20. +----+--------+--------------+--------------+
  21. | id | nombre | evento       | bonificacion |
  22. +----+--------+--------------+--------------+
  23. |  1 | SAUL   | METAL        |           10 |
  24. |  2 | ANA    | TURISMO      |            8 |
  25. |  3 | ANDRES | ALIMENTACION |            3 |
  26. +----+--------+--------------+--------------+
  27. 3 rows in set (0.00 sec)
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)