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 |
alisag
Starting Member
5 Posts |
Posted - 2014-01-20 : 03:57:40
|
Hi Folks,I have Following Tables. - Tariff Number
- Item
- Item Ledger Entry
The Relation Between these tables are Tariff Number.No_ = Item.Tariff No_ & Item. No_ = Item Ledger Entry.Item No_I want my Query to run for all the Tariff Numbers(PK is No_), loop through all the Item with that tariff No and Sum the Quantity in Item Ledger Entry Table for those Items.One Tariff Number can have many Items and one Item Can Have many Item Ledger Entries.I want to display,Tariff No Tariff Description Total_Quanity |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-01-20 : 04:07:11
|
[code]SELECT t.[No_], t.[Tariff Description], Total_Quanity = SUM(l.[Quantity])FROM [Tariff Number] t INNER JOIN [Item] i ON t.[No_] = i.[Tariff No_] INNER JOIN [Item Ledger Entry] l ON i.[No_] = l.[Item No_]GROUP BY t.[No_], t.[Tariff Description][/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
alisag
Starting Member
5 Posts |
Posted - 2014-01-20 : 04:22:30
|
Thanks a Lot KH. |
 |
|
|
|
|