SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old January 27th, 2004, 05:31 AM
jpor jpor is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 5 jpor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 20 m 41 sec
Reputation Power: 0
Unhappy Recordset bases in another to calculate (Sum)

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")?
--------------------------------------------------

Reply With Quote
  #2  
Old January 28th, 2004, 10:22 AM
unatratnag unatratnag is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 312 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 6 sec
Reputation Power: 6
Send a message via AIM to unatratnag
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.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Recordset bases in another to calculate (Sum)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT