﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / Development  / Select Decimal / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 18 May 2013 15:19:38 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Select Decimal</title><link>http://www.sqlservercentral.com/Forums/Topic406968-145-1.aspx</link><description>SUM(F1 - ROUND( F1, 0, 1)  worked great.  Thank you.</description><pubDate>Thu, 04 Oct 2007 13:36:00 GMT</pubDate><dc:creator>azzamein</dc:creator></item><item><title>RE: Select Decimal</title><link>http://www.sqlservercentral.com/Forums/Topic406968-145-1.aspx</link><description>You cound try something like:create table #junk (float_to_add float NOT NULL)goinsert #junk(float_to_add) values (1.1104)insert #junk(float_to_add) values (1.222)insert #junk(float_to_add) values (1.32)insert #junk(float_to_add) values (1.41)insert #junk(float_to_add) values (1.52)insert #junk(float_to_add) values (1.66)insert #junk(float_to_add) values (1.71)goselect float_to_add from #junkgoselect sum(convert(numeric(13,3),float_to_add) % 1.000) from #junkgodrop table #junkgoBut float is not an exact datatype, it's an approximation, so you may get some unexpected results because a number like 1.3 might actually come out as 1.29999999999.If the numbers you're storing need definite precision, float may not be the appropriate data type.</description><pubDate>Thu, 04 Oct 2007 11:48:50 GMT</pubDate><dc:creator>David Webb-CDS</dc:creator></item><item><title>RE: Select Decimal</title><link>http://www.sqlservercentral.com/Forums/Topic406968-145-1.aspx</link><description>Just use Round functionIF NOT OBJECT_ID('ANDRETEST') IS NULL 	DROP TABLE ANDRETESTGOCREATE TABLE ANDRETEST(F1 FLOAT, F2 CHAR(10))GOINSERT INTO ANDRETEST ( F1, F2 ) VALUES ( 160.2,'TEST')INSERT INTO ANDRETEST ( F1, F2 ) VALUES ( 100,'TEST')INSERT INTO ANDRETEST ( F1, F2 ) VALUES ( 79.5,'TEST')SELECT ROUND(SUM(F1 - ROUND( F1, 0, 1)), 1) AS TEST FROM ANDRETESTIF NOT OBJECT_ID('ANDRETEST') IS NULL 	DROP TABLE ANDRETESTGO</description><pubDate>Thu, 04 Oct 2007 11:48:07 GMT</pubDate><dc:creator>Andre St-Onge</dc:creator></item><item><title>Select Decimal</title><link>http://www.sqlservercentral.com/Forums/Topic406968-145-1.aspx</link><description>On an SQL 2005 Server I have a table column filled with float values.  What I want to do is sum up only the decimal portion of each value.  For example, for the values:160.210079.5The sum would be .7 (.5 + .2)My problem is that I am told Decimal is not a valid function, and I really don't want to have to loop through each value in code to pull out/add the decimals.Is there a way to do this in SQL 2005?</description><pubDate>Thu, 04 Oct 2007 11:09:58 GMT</pubDate><dc:creator>azzamein</dc:creator></item></channel></rss>