Explico, lo que quiero hacer es sacar el "OP" el cual se calcula de la siguiente forma:
OP=media-Target/target
La media es el promedio que muestro en mi codigo en la linea 56 y el target es el que muestro en la tabla html de la columna Target:
Código ASP:
Como vemos son 2 conexiones distintas, como puedo hacer este calculo? Ver original
<td><b>Linea</b></td> <td><b>Peso</b></td> <td><b>Target</b></td> <td><b>Marca</b></td> <td><b>Vaso</b></td> <td><b>Tubo</b></td> <td><b>Fecha</b></td> </tr> <% dim conexion,calendar1,calendar2,registros,linea,hora,test calendar1=request.form("calendar1") calendar2=request.form("calendar2") linea=request.form("linea") Tubo=request.form("tubo") hora=request.form("hora") test=("SELECT h.hora,h.marca,h.codoptima,h.target,P.CODOPTIMA,O.CODIGO,p.hora,p.peso,p.vaso,p.fecha, o.linea,o.tubo FROM pesos as p, optimas as o,htargets as h where o.codigo = p.codOptima and o.linea = '"&linea&"' and o.tubo LIKE '"&tubo&"' AND p.fecha Between '"&calendar1&"' AND '"&calendar2&"' AND p.hora='"&hora&"'and h.codoptima = o.codigo and h.hora='"&hora&"'") SET conexion=Server.CreateObject("ADODB.Connection") conexion.Open "PROVIDER=SQLOLEDB; DATA SOURCE=VALP-MESSRV02;UID=sa;PWD=messrv;DATABASE=wasp " SET registros=Server.CreateObject("ADODB.RecordSet") 'registros.open"SELECT peso,tubo from pesos where fecha between '"&calendar1&"' AND '"&calendar2&"'",conexion registros.open"SELECT h.hora,h.marca,h.codoptima,h.target,P.CODOPTIMA,O.CODIGO,p.hora,p.peso,p.vaso,p.fecha, o.linea,o.tubo FROM pesos as p, optimas as o,htargets as h where o.codigo = p.codOptima and o.linea = '"&linea&"' and o.tubo LIKE '"&tubo&"' AND p.fecha Between '"&calendar1&"' AND '"&calendar2&"' AND p.hora='"&hora&"'and h.codoptima = o.codigo and h.hora='"&hora&"'" ,conexion 'registros.open"SELECT p.hora,p.peso,p.vaso,p.fecha, o.linea,o.tubo FROM pesos as p, optimas as o where o.codigo = p.codOptima and o.linea = 'L15N' and o.tubo LIKE '%' AND p.fecha Between '2010-06-14 09:00:00.000' AND '2010-06-14 09:30:00.000' AND p.hora='9:00 - 9:30'" ,conexion 'SELECT h.codoptima,h.target,P.CODOPTIMA,O.CODIGO,p.hora,p.peso,p.vaso,p.fecha, o.linea,o.tubo,o.codigo FROM pesos as p, optimas as o,htargets as h where o.codigo = p.codOptima and o.linea = 'L07N' and o.tubo LIKE '%' AND p.fecha Between '2010-06-14 09:30' AND '2010-06-14 10:00' AND p.hora='9:30 - 10:00' and h.codoptima = o.codigo do while not registros.eof response.write("<tr>") response.write("<td>"®istros.fields("linea")&"</td>") response.write("<td>"®istros.fields("peso")&"</td>") response.write("<td>"®istros.fields("target")&"</td>") response.write("<td>"®istros.fields("marca")&"</td>") response.write("<td>"®istros.fields("vaso")&"</td>") response.write("<td>"®istros.fields("tubo")&"</td>") response.write("<td>"®istros.fields("fecha")&"</td>") registros.movenext loop conexion.close response.write(test) '<--Test Debug RESPONSE.WRITE("<br>") 'SELECT p.peso,p.tubo,p.fecha, o.linea FROM pesos as p, optimas as o where o.codigo = p.codOptima and o.linea = 'L02N' AND p.fecha Between '2010-05-11 09:42:34.000' AND '2010-05-11 09:42:39.000' 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") registros2.open"SELECT AVG(PESO)as peso from pesos where fecha Between '"&calendar1&"' AND '"&calendar2&"'",conexion2 do while not registros2.eof response.write("Promedio: "®istros2.fields("peso")&"") registros2.movenext loop conexion2.close %>