Ver Mensaje Individual
  #7 (permalink)  
Antiguo 15/06/2015, 12:27
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
¿Para qué usarás MIN()?

Probemos:
Código MySQL:
Ver original
  1. SELECT   t1.num, t2.total, ABS (t1.total - t2.total) diferencia
  2.     FROM tablavalores T1
  3.          INNER JOIN
  4.          (SELECT   num, SUM (valor1 + valor2 + valor3) total
  5.               FROM tablavalores
  6.              WHERE valor1 > 0
  7.                AND valor2 > 0
  8.                AND valor3 > 0
  9.           GROUP BY num) T2 ON T1.nbum = T2.num
  10. ORDER BY t2.total DESC, T1.total ASC;
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)