Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

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

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
Mcottuli
Asked:
Mcottuli
2 Solutions
 
Louis01Commented:
select Item, SUM(OnHand + Burn) as TotalQTY                  
  from bin
 group by Item

Open in new window

0
 
mlmccCommented:
Try something like

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

Open in new window


mlmcc
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now