Código ASP:
Ver original
SET conexion2=Server.CreateObject("ADODB.Connection") conexion2.Open "PROVIDER=SQLOLEDB; DATA SOURCE=VALP-MESSRV02;UID=sa;PWD=messrv;DATABASE=wasp " SET registros2=Server.CreateObject("ADODB.RecordSet") response.write("SELECT AVG(PESO)as promedio,o.linea from Optimas as o INNER JOIN pesos as p on o.codigo =p.codoptima WHERE fecha >='"&fecha&"' AND hora='"&horamia&"' AND o.linea='"&linea&"' GROUP BY LINEA") registros2.open"SELECT AVG(PESO)as promedio,o.linea from Optimas as o INNER JOIN pesos as p on o.codigo =p.codoptima WHERE fecha >='"&fecha&"' AND hora='"&horamia&"' AND o.linea='"&linea&"' GROUP BY LINEA",conexion2 do while not registros2.eof promedio=cint(registros2.fields("promedio")) 'c=(registros2.fields("peso")) 'b=(a-c)/target OP=(promedio-target)/target response.write("Promedio: <b>"®istros2.fields("promedio")&"</b><br>") '############## Aritmetica #################### ' C = Promedio WHERE B=(a-c)/a ' A = Target saving=(PROMEDIO-target)*NumBolsas if OP<=0 then response.write(" Op: <b>"&OP&"</b><img src='http://www.pact-oil.co.uk/images/error.gif'</a><br>") else response.write(" Op: <b>"&OP&"</b><img src='http://www.hospitalsierrallana.com/imagenes/gif_ok.gif'</a><br>") end if response.write("Saving:<b> "&saving&" KG</b>") registros2.movenext loop conexion2.close