?
Solved

SQL Server Select CAST and SUM

Posted on 2014-08-12
2
Medium Priority
?
831 Views
Last Modified: 2014-08-24
I need to change the CAST of column and also SUM the column.  How can I do this?

SELECT CAST([ProductTaxonomy.csv].[YTD Sales Amount] AS numeric) as Total
FROM [ProductTaxonomy.csv]
INNER JOIN [Product Management.csv] ON [ProductTaxonomy.csv].[Product Code] = [Product Management.csv].[Product_Code]
0
Comment
Question by:hojohappy
2 Comments
 
LVL 49

Accepted Solution

by:
PortletPaul earned 1000 total points
ID: 40257306
SELECT SUM( CAST([ProductTaxonomy.csv].[YTD Sales Amount] AS decimal(18,4)) ) as Total
FROM [ProductTaxonomy.csv]
INNER JOIN [Product Management.csv] ON [ProductTaxonomy.csv].[Product Code] = [Product Management.csv].[Product_Code]

+edit:
you didn't mention what type you wanted to cast to, so I picked a decimal.
0
 
LVL 11

Assisted Solution

by:HuaMinChen
HuaMinChen earned 1000 total points
ID: 40257561
Try
SELECT CAST([ProductTaxonomy.csv].[YTD Sales Amount] AS decimal(18,4)) as Total
FROM [ProductTaxonomy.csv]
INNER JOIN [Product Management.csv] ON [ProductTaxonomy.csv].[Product Code] = [Product Management.csv].[Product_Code]

Open in new window

0

Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

862 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