<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Get Answer in Float When Dividing of Two Integer</title>
	<atom:link href="http://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 17 May 2013 15:26:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: avi</title>
		<link>http://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/#comment-466082</link>
		<dc:creator><![CDATA[avi]]></dc:creator>
		<pubDate>Mon, 29 Apr 2013 10:47:22 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1185#comment-466082</guid>
		<description><![CDATA[thank you  better than msdn]]></description>
		<content:encoded><![CDATA[<p>thank you  better than msdn</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jorgen Harmse</title>
		<link>http://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/#comment-437319</link>
		<dc:creator><![CDATA[Jorgen Harmse]]></dc:creator>
		<pubDate>Thu, 14 Mar 2013 16:58:41 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1185#comment-437319</guid>
		<description><![CDATA[Certainly it produces a float, but I don&#039;t think the value is what the original post wanted. The integer divide has to happen first, and the result of that is converted to float. A / (B * 1.0) and A * 1.0 / B b both perform floating point division.


&gt; sqldf(&quot;select 8 / 3 * 1.0&quot;)
  8 / 3 * 1.0
1           2]]></description>
		<content:encoded><![CDATA[<p>Certainly it produces a float, but I don&#8217;t think the value is what the original post wanted. The integer divide has to happen first, and the result of that is converted to float. A / (B * 1.0) and A * 1.0 / B b both perform floating point division.</p>
<p>&gt; sqldf(&#8220;select 8 / 3 * 1.0&#8243;)<br />
  8 / 3 * 1.0<br />
1           2</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jorgen Harmse</title>
		<link>http://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/#comment-437314</link>
		<dc:creator><![CDATA[Jorgen Harmse]]></dc:creator>
		<pubDate>Thu, 14 Mar 2013 16:41:30 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1185#comment-437314</guid>
		<description><![CDATA[Certainly this produces a float, but the value depends on precedence of / &amp; *, which is non-obvious to casual readers. I would specify A / (B * 1.0) or (A / B) * 1.0 or A * 1.0 / B. The first &amp; third do what the original questioner wanted. The second does integer division and turns the answer into a float.]]></description>
		<content:encoded><![CDATA[<p>Certainly this produces a float, but the value depends on precedence of / &amp; *, which is non-obvious to casual readers. I would specify A / (B * 1.0) or (A / B) * 1.0 or A * 1.0 / B. The first &amp; third do what the original questioner wanted. The second does integer division and turns the answer into a float.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mahesh Chikhale</title>
		<link>http://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/#comment-416726</link>
		<dc:creator><![CDATA[Mahesh Chikhale]]></dc:creator>
		<pubDate>Sat, 02 Feb 2013 11:34:11 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1185#comment-416726</guid>
		<description><![CDATA[hello sir my table is able to store the float value like 75.5 but if i am going to store  like 125.00,50.00 etc it will store 125 , 50 not giving me decimal places
what is the solution if i want to store the values with 00 in decimal places?]]></description>
		<content:encoded><![CDATA[<p>hello sir my table is able to store the float value like 75.5 but if i am going to store  like 125.00,50.00 etc it will store 125 , 50 not giving me decimal places<br />
what is the solution if i want to store the values with 00 in decimal places?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse Anderson</title>
		<link>http://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/#comment-360340</link>
		<dc:creator><![CDATA[Jesse Anderson]]></dc:creator>
		<pubDate>Mon, 15 Oct 2012 14:40:45 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1185#comment-360340</guid>
		<description><![CDATA[Thanks for the post Dave et al. I must say, after beginning my professional career as a developer, your blog has been a top reference of mine (along with MSDN of ciurse) when I need help solving a problem with SQL.]]></description>
		<content:encoded><![CDATA[<p>Thanks for the post Dave et al. I must say, after beginning my professional career as a developer, your blog has been a top reference of mine (along with MSDN of ciurse) when I need help solving a problem with SQL.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/#comment-265313</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Tue, 20 Mar 2012 12:14:40 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1185#comment-265313</guid>
		<description><![CDATA[select round(col,2)]]></description>
		<content:encoded><![CDATA[<p>select round(col,2)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nowfal majeed</title>
		<link>http://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/#comment-260353</link>
		<dc:creator><![CDATA[Nowfal majeed]]></dc:creator>
		<pubDate>Wed, 07 Mar 2012 10:59:15 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1185#comment-260353</guid>
		<description><![CDATA[Thank You very much for this examples..I have tried i got answer..But one thing if i need 1.20 instead of 1.2089876 what i have to do?]]></description>
		<content:encoded><![CDATA[<p>Thank You very much for this examples..I have tried i got answer..But one thing if i need 1.20 instead of 1.2089876 what i have to do?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Happy Web Designer</title>
		<link>http://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/#comment-58422</link>
		<dc:creator><![CDATA[Happy Web Designer]]></dc:creator>
		<pubDate>Fri, 11 Dec 2009 07:38:11 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1185#comment-58422</guid>
		<description><![CDATA[Excellent,

This one had me stumped.

To get a percentage with decimal places

100.0*@numerator/@denominator

where both are INT and extract as float.

Job done. 

Thank you.]]></description>
		<content:encoded><![CDATA[<p>Excellent,</p>
<p>This one had me stumped.</p>
<p>To get a percentage with decimal places</p>
<p>100.0*@numerator/@denominator</p>
<p>where both are INT and extract as float.</p>
<p>Job done. </p>
<p>Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Darren</title>
		<link>http://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/#comment-53922</link>
		<dc:creator><![CDATA[Darren]]></dc:creator>
		<pubDate>Tue, 21 Jul 2009 14:23:26 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1185#comment-53922</guid>
		<description><![CDATA[This has caught me many times...
Putting the 1.0 at the beginning of the line makes a difference:

declare @a int,@b int,@c float
set @a=1
set @b=2

select @a/@b - Result 0
select @a/@b*1.0 - Result 0.0
select 1.0*@a/@b - Result 0.500000]]></description>
		<content:encoded><![CDATA[<p>This has caught me many times&#8230;<br />
Putting the 1.0 at the beginning of the line makes a difference:</p>
<p>declare @a int,@b int,@c float<br />
set @a=1<br />
set @b=2</p>
<p>select @a/@b &#8211; Result 0<br />
select @a/@b*1.0 &#8211; Result 0.0<br />
select 1.0*@a/@b &#8211; Result 0.500000</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - Puzzle - Solution - Computed Columns Datatype Explanation Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/#comment-43346</link>
		<dc:creator><![CDATA[SQL SERVER - Puzzle - Solution - Computed Columns Datatype Explanation Journey to SQL Authority with Pinal Dave]]></dc:creator>
		<pubDate>Mon, 29 Sep 2008 01:31:40 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1185#comment-43346</guid>
		<description><![CDATA[[...] SQL SERVER - Get Answer in Float When Dividing of Two Integer SQL SERVER - Puzzle - Computed Columns Datatype Explanation SQL SERVER - Puzzle - Solution - Computed Columns Datatype Explanation [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SQL SERVER &#8211; Get Answer in Float When Dividing of Two Integer SQL SERVER &#8211; Puzzle &#8211; Computed Columns Datatype Explanation SQL SERVER &#8211; Puzzle &#8211; Solution &#8211; Computed Columns Datatype Explanation [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marek Śliwiński</title>
		<link>http://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/#comment-43332</link>
		<dc:creator><![CDATA[Marek Śliwiński]]></dc:creator>
		<pubDate>Sun, 28 Sep 2008 09:39:25 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1185#comment-43332</guid>
		<description><![CDATA[Thanks guys, you make a nice duet together :)
Very interesting about this precedence.]]></description>
		<content:encoded><![CDATA[<p>Thanks guys, you make a nice duet together :)<br />
Very interesting about this precedence.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - Puzzle - Computed Columns Datatype Explanation Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/#comment-43311</link>
		<dc:creator><![CDATA[SQL SERVER - Puzzle - Computed Columns Datatype Explanation Journey to SQL Authority with Pinal Dave]]></dc:creator>
		<pubDate>Sat, 27 Sep 2008 01:31:10 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1185#comment-43311</guid>
		<description><![CDATA[[...] 27, 2008 by pinaldave    Yesterday I wrote post about SQL SERVER - Get Answer in Float When Dividing of Two Integer. I received excellent comment from SQL Server MVP Jacob Sebastian. Jacob has clearified the concept [...]]]></description>
		<content:encoded><![CDATA[<p>[...] 27, 2008 by pinaldave    Yesterday I wrote post about SQL SERVER &#8211; Get Answer in Float When Dividing of Two Integer. I received excellent comment from SQL Server MVP Jacob Sebastian. Jacob has clearified the concept [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jerry Hung</title>
		<link>http://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/#comment-43292</link>
		<dc:creator><![CDATA[Jerry Hung]]></dc:creator>
		<pubDate>Fri, 26 Sep 2008 14:23:07 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1185#comment-43292</guid>
		<description><![CDATA[Sometimes I get lazy and just do 
field = int column A / int column B * 1.0

Then I *think* I get float back]]></description>
		<content:encoded><![CDATA[<p>Sometimes I get lazy and just do<br />
field = int column A / int column B * 1.0</p>
<p>Then I *think* I get float back</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/#comment-43281</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Fri, 26 Sep 2008 10:14:35 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1185#comment-43281</guid>
		<description><![CDATA[Thank you Jacob,

I like your additional explanation. I just realize after reading your explanation that I should include your explanation in the post itself so it is visible to everybody right away. 

Also this has brought another idea in my mind that when creating calculated field the same scenario happens. E.g. When we create calculated field from additions of INT it will give us final calculated field as INT. If we want that in another datatype we should have either follow your suggestion or CAST them.

Regards,
Pinal]]></description>
		<content:encoded><![CDATA[<p>Thank you Jacob,</p>
<p>I like your additional explanation. I just realize after reading your explanation that I should include your explanation in the post itself so it is visible to everybody right away. </p>
<p>Also this has brought another idea in my mind that when creating calculated field the same scenario happens. E.g. When we create calculated field from additions of INT it will give us final calculated field as INT. If we want that in another datatype we should have either follow your suggestion or CAST them.</p>
<p>Regards,<br />
Pinal</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacob sebastian</title>
		<link>http://blog.sqlauthority.com/2008/09/26/sql-server-division-by-float/#comment-43276</link>
		<dc:creator><![CDATA[Jacob sebastian]]></dc:creator>
		<pubDate>Fri, 26 Sep 2008 09:10:32 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1185#comment-43276</guid>
		<description><![CDATA[Nice post and something that is very much useful in the day-to-day programming life.

Just wanted to add to what is already explained, that, SQL Server automatically does a cast to the data type having the highest precedence. So the result of INT and INT will be INT, but INT and FLOAT will be FLOAT because FLOAT has a higher precedence. If you want a different data type, you need to do an EXPLICIT cast.

For example:

SELECT 100/3 AS Result
/*
Result
-----------
33
*/

SELECT 100/3.0 AS Result
/*
Result
---------------------------------------
33.333333
*/

The precedence of each data type is documented here: http://msdn.microsoft.com/en-us/library/ms190309(SQL.90).aspx]]></description>
		<content:encoded><![CDATA[<p>Nice post and something that is very much useful in the day-to-day programming life.</p>
<p>Just wanted to add to what is already explained, that, SQL Server automatically does a cast to the data type having the highest precedence. So the result of INT and INT will be INT, but INT and FLOAT will be FLOAT because FLOAT has a higher precedence. If you want a different data type, you need to do an EXPLICIT cast.</p>
<p>For example:</p>
<p>SELECT 100/3 AS Result<br />
/*<br />
Result<br />
&#8212;&#8212;&#8212;&#8211;<br />
33<br />
*/</p>
<p>SELECT 100/3.0 AS Result<br />
/*<br />
Result<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
33.333333<br />
*/</p>
<p>The precedence of each data type is documented here: <a href="http://msdn.microsoft.com/en-us/library/ms190309(SQL.90)" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms190309(SQL.90)</a>.aspx</p>
]]></content:encoded>
	</item>
</channel>
</rss>
