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.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Sum, Group and Details

Author  Topic 

alisag
Starting Member

5 Posts

Posted - 2014-05-28 : 04:53:17
Hi,
I have a TABLE called Item and from this Table I Need Item No. & Item Description. There is a Table called Item Ledger and from This Table I Need Sum of Remaining Quantities. So i wrote my Query like,
Select Item.No_,Item.Description,SUM(ILE.[Remaining Quantity]) AS Inventory
From dbo.[123 FC$Item] as Item
INNER JOIN dbo.[123 FC$Item Ledger Entry] As ILE ON
Item.[No_] = ILE.[Item No_]

Lets say i have another Table called BIN( An Item Can have many BINs) which have PK as Item no. AND Bin No.. Now the BIN Quantity is calculated from a Warehouse Table.
So how can I show the report in the below format,


Item No. Description Inventory Bin No. Quanity

XXXX XXXXXXX 10
--------------------------------------
A 2
--------------------------------------
B 6
--------------------------------------
C 2

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-05-28 : 07:48:21
Please post:

1. DDL (Create Table commands) for each table involved
2. DML (INsert into commands) to populate each table with sample data
3. The desired result of the query you need.
Go to Top of Page
   

- Advertisement -