|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
In Access i can do this:
---------------------------- QUERY: c4 SELECT codMediador, refProduto, 0 as valor FROM Mediador, Produto ORDER BY codMediador, refProduto; UNION SELECT codMediador, refProduto, quantidade FROM MedProd; QUERY: D SELECT DISTINCTROW c4.codMediador, c4.refProduto, Sum(valor) AS Soma FROM c4 GROUP BY c4.codMediador, c4.refProduto; In ASP i have: ----------------- Set conn = Server.CreateObject("ADODB.Connection") conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.Mappath("med.mdb") Set rs = Server.CreateObject("ADODB.Recordset") ComandoSQL = "SELECT codMediador, refProduto, 0 FROM Mediador, Produto" ComandoSQL = ComandoSQL & " ORDER BY codMediador ASC, refProduto ASC" ComandoSQL = ComandoSQL & " UNION SELECT codMediador, refProduto, quantidade FROM MedProd" Set rs=conn.execute(ComandoSQL) And then? How i write my second Recordset ("D")? -------------------------------------------------- |
|
#2
|
|||
|
|||
|
If it's nothing is stopping you, why not just combine all of this into one query?
but if you want to keep it separate you could refer to the other recordset by saying rs("columnname") and just put that into the string such as SQL = "SELECT " & rs("columnname") & " WHERE etc..." Last edited by unatratnag : January 28th, 2004 at 10:25 AM. |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Recordset bases in another to calculate (Sum) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|