• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

SQL Select Question

Tencntraze

Senior member
For simplicity, let's say that my current table has three fields:

Part# (not unique)
NumInStock
SupplierName

Basically, I want to do a select statement the sums up the total number of items in stock across all suppliers. So basically lets say that two of the rows are:

Part # | NumInStock | SupplierName
-------------------------------------------------
ABC | 3 | Supplier1
ABC | 5 | Supplier2

What I want returned from my select statement is:


Part # | NumInStock
----------------------------
ABC | 8

I'm sure this is pretty common, but it's been a while since I've had to do all that much SQL and figure this is the kind of thing that would be better done by the DB than the application.
 
Originally posted by: Snapster
Select PartNum, Sum(NumInStock) As TotalStock from Table
Group by PartNum

It's always good practice to give expression fields an alias. 🙂
 
Back
Top