Solved

I need a sql view to return a total from and existing table

Posted on 2013-11-25
2
256 Views
Last Modified: 2013-11-29
I am looking for a query/view to add to a database to retrieve and combine data from an existing table. Table named "Bin" for the purpose of a crystal report. The table consists of 1000's of items, many duplicates in different bins with a different on hand and burn QTY. The results should not duplicate items, should not list any bin but should add the OnHand and burn QTY of duplicate items as TotalQTY

Item Bin      OnHand      Burn      
abc        1           2                 0      
dgf       2           3                 0      
abc       3           4                 3      
abc       4           8            8      
acdf       5           0                 0      
dgf       6           0                 0      
xyz       7           1               1
                        
                        
                        
Query should combine like items and add their onHand and burn colums to return the below results      
                  
Item         TotalQTY                  
abc            25                  
dgf             3                  
acdf             0
xyz          2
0
Comment
Question by:Mcottuli
2 Comments
 
LVL 11

Accepted Solution

by:
Louis01 earned 250 total points
ID: 39676693
select Item, SUM(OnHand + Burn) as TotalQTY                  
  from bin
 group by Item

Open in new window

0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 250 total points
ID: 39676695
Try something like

Select Item, Sum(OnHand) + Sum(Burn) as TotalQty
From TableBin
Group By Item

Open in new window


mlmcc
0

Featured Post

[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now