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
 General SQL Server Forums
 New to SQL Server Programming
 Nested Select

Author  Topic 

alisag
Starting Member

5 Posts

Posted - 2015-01-09 : 03:48:34
Hi Experts,
A newbie here. So please be kind :-)
I have 2 Tables namely Item & Item Entries. relation is Item.No = ItemEntries.No. In Item Entries Table I have Columns as Qty,Entry type,Purchase Amount,Sales Amount
I like to have a report which Shows as Below,
Item No. Opening Quantity Purcahse Amount Sales Amount
To calculate Opening Inventory I summed up the quantity field and the result is as expected. No problem in that. Now From that dataset i like to run a sub query which Calcualtes/Sum the Purchase amount for an Item that i sa part of first dataset and similarly for Sales Amount.

e.g. Select(Item No.,Sum(IE.Quantity) As Quantity, Select(......Purchase Amount),Select(....Sales Amount)
I hope i was able to clear my doubts to you guys.

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2015-01-09 : 07:17:30
Post some sample data of Items and ItemEntries tables and also the expected output for that data....

It will be helpful to get quick responses....

--
Chandu
Go to Top of Page
   

- Advertisement -