Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nestled query question?

Status
Not open for further replies.

Linkan

Programmer
Feb 7, 2001
44
0
0
SE
Hi i am trying to make a nestled query to get the total sum of my accounts. My question is how to make a query to handle this?

I have two tables.

tbAccount

lngAccountID strName
1 A1
2 A2
3 A3
4 A4

Now I want to SUM lngPrice for all the accounts.

tbTransaction

lngTransID lngAccountID lngPrice
1 2 500
2 2 250
3 1 100
4 2 175
5 3 100
6 4 200
7 3 100
8 1 800

I want to present it as follow.

Account Total
A1 900
A2 925
A3 200
A4 200

How do I do this?
Thanks for a great forum!

//Linkan

 
[tt]select strName as Account
, sum(lngPrice) as Total
from tbTransaction
inner
join tbAccount
on tbTransaction.lngAccountID
= tbAccount.lngAccountID
group
by strName[/tt]


rudy
 
Thanks Rudy!
Great job, it works perfect :)

Regards,
Linkan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top