Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
clean
Starting Member
7 Posts |
Posted - 2006-05-04 : 13:05:00
|
| table A has locations that relate to table BaID city1 toronto2 londontable B has the followingbid aID ordernum amount1 1 555 50002 1 345 70003 1 236 30004 2 638 70505 2 434 5755and so onwhat i need my select statement to do if it's even possible is total the amounts grouped by aID and display the city from table A and the total from table B |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2006-05-04 : 13:10:26
|
| Pretty basic stuff. JOIN the 2 tables by aID, GROUP BY aID, SELECT aID along with the aggregate function COUNT.All key words are detailed with examples in the help that comes with Sql Server: Books Online.Be One with the OptimizerTG |
 |
|
|
druer
Constraint Violating Yak Guru
314 Posts |
Posted - 2006-05-04 : 13:18:29
|
| Select a.aID, SUM(b.amount) as AmountTotalfrom TableA a inner join TableB b on b.aID = a.IDgroup by a.aIDHope it helps,DaltonBlessings aren't so much a matter of "if they come" but "are you noticing them." |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|