Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to sum a text col. containing numeric data (numbers)

Status
Not open for further replies.

wec43wec

Technical User
Aug 6, 2005
226
US
I have a column (ex - Col B) containing numbers that I need to create a total when changes occur within a second column

Example column A contains "product name" and column "B" contain the actual number of products/type.

Col A Col B
apple 5
apple 6
apple 2
orange 1
orange 9
orange 4

Desried result

Apple - 13
orange- 14


It is my understanding that the task requires a coding of "decimal" prior to the "select" option in column B.

Any help would be greatly appreciated.

Thanks
 
Hi,
try this code, please change x2 to your table name and do the same for columns names.

SELECT Product, SUM(CONVERT(INT,quantity))
FROM x2
GROUP BY Product
ORDER BY Product

good luck

Walid Magd (MCP)

The primary challenge of every software development team is to engineer the illusion of simplicity in the face of essential complexity.
-Grady Booch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top