<?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>Repeated String &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/repeated-string/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Wed, 21 Jun 2017 20:20:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>SQL Server Interview: Advance SQL Query &#8211; Find a count of repeated character in a String</title>
		<link>https://www.dbrnd.com/2017/06/sql-server-interview-advance-sql-query-find-a-count-of-repeated-character-in-a-string/</link>
					<comments>https://www.dbrnd.com/2017/06/sql-server-interview-advance-sql-query-find-a-count-of-repeated-character-in-a-string/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 01 Jun 2017 16:16:31 +0000</pubDate>
				<category><![CDATA[SQL Puzzle]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[Complex SQL Query]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Repeated String]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[string count]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5354</guid>

					<description><![CDATA[In this post, I am sharing one complex SQL Query interview question and solution for T-SQL Developers. Last week, I asked this question to one of the T-SQL Developer. If you are going for database developer interview, you must find and practice complex or advance SQL Queries. Question: Find a count of given repeated character [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fsql-server-interview-advance-sql-query-find-a-count-of-repeated-character-in-a-string%2F&amp;linkname=SQL%20Server%20Interview%3A%20Advance%20SQL%20Query%20%E2%80%93%20Find%20a%20count%20of%20repeated%20character%20in%20a%20String" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fsql-server-interview-advance-sql-query-find-a-count-of-repeated-character-in-a-string%2F&amp;linkname=SQL%20Server%20Interview%3A%20Advance%20SQL%20Query%20%E2%80%93%20Find%20a%20count%20of%20repeated%20character%20in%20a%20String" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fsql-server-interview-advance-sql-query-find-a-count-of-repeated-character-in-a-string%2F&amp;linkname=SQL%20Server%20Interview%3A%20Advance%20SQL%20Query%20%E2%80%93%20Find%20a%20count%20of%20repeated%20character%20in%20a%20String" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fsql-server-interview-advance-sql-query-find-a-count-of-repeated-character-in-a-string%2F&amp;linkname=SQL%20Server%20Interview%3A%20Advance%20SQL%20Query%20%E2%80%93%20Find%20a%20count%20of%20repeated%20character%20in%20a%20String" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fsql-server-interview-advance-sql-query-find-a-count-of-repeated-character-in-a-string%2F&amp;linkname=SQL%20Server%20Interview%3A%20Advance%20SQL%20Query%20%E2%80%93%20Find%20a%20count%20of%20repeated%20character%20in%20a%20String" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fsql-server-interview-advance-sql-query-find-a-count-of-repeated-character-in-a-string%2F&amp;linkname=SQL%20Server%20Interview%3A%20Advance%20SQL%20Query%20%E2%80%93%20Find%20a%20count%20of%20repeated%20character%20in%20a%20String" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fsql-server-interview-advance-sql-query-find-a-count-of-repeated-character-in-a-string%2F&#038;title=SQL%20Server%20Interview%3A%20Advance%20SQL%20Query%20%E2%80%93%20Find%20a%20count%20of%20repeated%20character%20in%20a%20String" data-a2a-url="https://www.dbrnd.com/2017/06/sql-server-interview-advance-sql-query-find-a-count-of-repeated-character-in-a-string/" data-a2a-title="SQL Server Interview: Advance SQL Query – Find a count of repeated character in a String"></a></p><p>In this post, I am sharing one complex SQL Query interview question and solution for T-SQL Developers. </p>
<p>Last week, I asked this question to one of the T-SQL Developer.<br />
If you are going for database developer interview, you must find and practice complex or advance SQL Queries.</p>
<p><strong>Question:</strong> Find a count of given repeated character from a string</p>
<p><strong>Create a table with sample data:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_Strings (name VARCHAR(30))
GO

INSERT INTO tbl_Strings
VALUES
('India'),('Southern Europe')
,('Japan'),('Indonesia')
,('Swaziland'),('South Africa')
,('United Arab Emirates'),('United States')
GO</pre> </p>
<p><strong>Solution:</strong></p>
<pre class="crayon-plain-tag">;WITH CTE AS
(
		SELECT name, CONVERT(VARCHAR(1),LEFT(name,1)) AS Letter, RIGHT(name, LEN(name)-1) AS Remain
		FROM tbl_Strings
		WHERE LEN(name)&gt;1
	UNION ALL
		SELECT name, CONVERT(VARCHAR(1),LEFT(Remain,1)) AS Letter, 
			RIGHT(Remain, LEN(Remain)-1) AS Remain
		FROM CTE
		WHERE LEN(Remain)&gt;0
)
SELECT 
	name
	,Letter
	,ASCII(Letter) AS CharAsciiCode
	,COUNT(Letter) AS CountOfLetter
FROM CTE
WHERE Letter IN('a','A')
GROUP BY name, Letter, ASCII(Letter)</pre> </p>
<p><strong>The Result:</strong></p>
<pre class="crayon-plain-tag">name                           Letter CharAsciiCode CountOfLetter
------------------------------ ------ ------------- -------------
South Africa                   A      65            1
United Arab Emirates           A      65            1
India                          a      97            1
Indonesia                      a      97            1
Japan                          a      97            2
South Africa                   a      97            1
Swaziland                      a      97            2
United Arab Emirates           a      97            2
United States                  a      97            1</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/06/sql-server-interview-advance-sql-query-find-a-count-of-repeated-character-in-a-string/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
