Click here to Skip to main content
15,923,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have 2 table. tblCurrTrx and tblTransaction.
tblCurrTrx store the transaction data. tblTransaction store the Transaction ID, Description.

On tblCurrTrx also have column TransID. How to write sql statement to select the total amount in tblCurrTrx.dblAmount where the tblCurrTrx.TransID = tblTransaction.TransID?

On tblTransaction, I have 2 value only, that's is S01 and S02. So in tblCurrTrx, there is 10 transaction that have 4 S01 and 6 S02. And I want to run a query to select the sum amount of S01. Second query will get the sum of S02. Can anyone explain? I have made some query here. But it's failed.

VB
strSQl="SELECT tblCurrTrx, SUM (tblCurrTrx.dblAmount) WHERE " & _
tblCurrTrx.TransID=tblTransaction.TransID AND " & _
tblCurrTrx.CollectionNo='" & strCollectNo & "' GROUP BY tblTransaction.TransID"


My pal said I should use INNER JOIN but I have no idea how to write it. Please help
Posted

1 solution

This should get you started ..http://msdn.microsoft.com/en-us/library/office/bb243855(v=office.12).aspx[^]

I would suggest trying it out in SQL first until you get it to work, and then convert it into your code ("strSql = ...etc") - you'll get more meaningful error messages that should help you spot what you're doing wrong. For example you don't have FROM clause in the example above
 
Share this answer
 
Comments
Maciej Los 15-Apr-13 5:45am    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900