<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>½ in SQL Server - MSSQL Query</title>
	<atom:link href="https://mssqlquery.com/tag/%C2%BD-in-sql-server/feed" rel="self" type="application/rss+xml" />
	<link>https://mssqlquery.com</link>
	<description>MSSQL and TSQL Programming and TSQL Examples</description>
	<lastBuildDate>Sat, 13 May 2023 19:35:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.3.1</generator>

<image>
	<url>https://mssqlquery.com/wp-content/uploads/2023/06/cropped-mssql-query-icon-32x32.png</url>
	<title>½ in SQL Server - MSSQL Query</title>
	<link>https://mssqlquery.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Analyzing ½ in SQL Server Mathematically</title>
		<link>https://mssqlquery.com/analyzing-%c2%bd-in-sql-server-mathematically</link>
		
		<dc:creator><![CDATA[Yavuz Selim Kart]]></dc:creator>
		<pubDate>Sat, 13 May 2023 19:35:00 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[½ in SQL Server]]></category>
		<category><![CDATA[SQL Server Mathematically]]></category>
		<category><![CDATA[SQL Server tricks]]></category>
		<guid isPermaLink="false">https://mssqlquery.com/?p=1554</guid>

					<description><![CDATA[<p>Hello everyone. In this article, we will analyze ½, that is, a part 2, expression in SQL Server mathematically. In SQL Server, you may come across such questions in interviews or while writing a query. This is a small question. However, it&#8217;s also an interesting question. Many people immediately answer&#46;&#46;&#46;</p>
<p>The post <a href="https://mssqlquery.com/analyzing-%c2%bd-in-sql-server-mathematically">Analyzing ½ in SQL Server Mathematically</a> first appeared on <a href="https://mssqlquery.com">MSSQL Query</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Hello everyone. In this article, we will analyze ½, that is, a part 2, expression in SQL Server mathematically.</p>
<p>In SQL Server, you may come across such questions in interviews or while writing a query. This is a small question. However, it&#8217;s also an interesting question. Many people immediately answer &#8220;0.5&#8221;. It&#8217;s mathematically correct, but it&#8217;s hard to say for SQL Server that this is so. Because if you do this in SQL Server, you will see the result of &#8220;0&#8221;.</p>
<p>Try the following query on SQL Server Management Studio.</p>
<pre class="line-numbers"><code class="language-sql">SELECT 1/2 AS Sonuc</code></pre>
<p>If you saw the zero result, read on.</p>
<p>The reason ½ is &#8220;0&#8221; in SQL Server is because SQL Server treats 1 and 2 as integers.</p>
<p>If we change our queries as below, we will catch the expression &#8220;0.5&#8221; according to the data types.</p>
<pre class="line-numbers"><code class="language-sql">SELECT
	1 / 2 AS Sonuc1
SELECT
	1.0 / 2.0 AS Sonuc2
SELECT
	CONVERT(FLOAT, 1) / 2 AS Sonuc3
SELECT
	1 / CONVERT(FLOAT, 2) AS Sonuc4
SELECT
	CONVERT(FLOAT, 1) / CONVERT(FLOAT, 2) AS Sonuc5
SELECT
	CAST(1 AS FLOAT) / 2 AS Sonuc6
SELECT
	1 / CAST(2 AS FLOAT) AS Sonuc7
SELECT
	CAST(1 AS FLOAT) / CAST(2 AS FLOAT) AS Sonuc8
SELECT
	CONVERT(NUMERIC(5, 2), 1.0 / 2.0) AS Sonuc9</code></pre>
<p>When you run the above query, you will see a result similar to the one below.</p>
<p><img decoding="async" fetchpriority="high" class="alignnone wp-image-1557 size-full" src="https://mssqlquery.com/wp-content/uploads/2023/05/analyzing-½-in-sql-server-mathematically-1.jpg" alt="Analyzing ½ in SQL Server Mathematically" width="700" height="567" srcset="https://mssqlquery.com/wp-content/uploads/2023/05/analyzing-½-in-sql-server-mathematically-1.jpg 700w, https://mssqlquery.com/wp-content/uploads/2023/05/analyzing-½-in-sql-server-mathematically-1-300x243.jpg 300w" sizes="(max-width: 700px) 100vw, 700px" /></p>
<p>As can be seen, we have obtained the result &#8220;0.5&#8221;.</p>
<p>Good luck to everyone in business and life.</p>
<div class='epvc-post-count'><span class='epvc-eye'></span>  <span class="epvc-count"> 32</span><span class='epvc-label'> Views</span></div><p>The post <a href="https://mssqlquery.com/analyzing-%c2%bd-in-sql-server-mathematically">Analyzing ½ in SQL Server Mathematically</a> first appeared on <a href="https://mssqlquery.com">MSSQL Query</a>.</p>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
