Ver Mensaje Individual
  #7  
Antiguo 21-04-2008
Avatar de jachguate
jachguate jachguate is offline
Miembro
 
Registrado: may 2003
Ubicación: Guatemala
Posts: 6.254
Reputación: 30
jachguate Va por buen camino
Bueno, compañeros... eso depende de las capacidades del motor. Si es oracle, firebird 2.0 o SQL Server, podrías hacer esto, que suelen llamar inline views o tablas derivadas:

Código SQL [-]
select q1.total_gordo, q1.total_general, 100 * q1.total_gordo / q1.total_general
  from (  
      Select sum(l.lin_kgsnetos) Total_gordo, 
               (Select sum(lin_kgsnetos) from lineas_entrada l2 where l2.lin_socio = l.lin_socio) total_general,
        from lineas_entrada l
       where lin_socio = 4
         and lin_variedad = 'GORDO'
  ) q1;

Hasta luego.

__________________
Juan Antonio Castillo Hernández (jachguate)
Guía de Estilo | Etiqueta CODE | Búsca antes de preguntar | blog de jachguate
Responder Con Cita