<?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/"
		>
<channel>
	<title>Comments on: How to solve the Anagrams Puzzle in SQL</title>
	<atom:link href="http://oraqa.com/2010/06/08/how-to-solve-the-anagrams-puzzle-in-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://oraqa.com/2010/06/08/how-to-solve-the-anagrams-puzzle-in-sql/</link>
	<description>Oracle Question and Answer</description>
	<lastBuildDate>Mon, 19 Dec 2011 14:21:07 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: newkid</title>
		<link>http://oraqa.com/2010/06/08/how-to-solve-the-anagrams-puzzle-in-sql/comment-page-1/#comment-272</link>
		<dc:creator>newkid</dc:creator>
		<pubDate>Thu, 24 Jun 2010 21:19:38 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/?p=521#comment-272</guid>
		<description>&lt;pre&gt;
SELECT w,wmsys.wm_concat(str),COUNT(*) cnt
  FROM (
SELECT str,REPLACE(SYS_CONNECT_BY_PATH(c,&#039;/&#039;),&#039;/&#039;) w
  FROM (
SELECT str
      ,SUBSTR(str,rn,1) c 
      ,ROW_NUMBER() OVER(PARTITION BY str ORDER BY SUBSTR(str,rn,1)) rn
  FROM words, (SELECT ROWNUM rn FROM DUAL CONNECT BY ROWNUM&lt;=(SELECT MAX(LENGTH(str)) FROM words))
 WHERE rn&lt;=LENGTH(str)
 )
WHERE CONNECT_BY_ISLEAF=1
START WITH rn=1
CONNECT BY str=PRIOR str AND rn = PRIOR rn+1
)
GROUP BY w
ORDER BY cnt DESC;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<pre>
SELECT w,wmsys.wm_concat(str),COUNT(*) cnt
  FROM (
SELECT str,REPLACE(SYS_CONNECT_BY_PATH(c,'/'),'/') w
  FROM (
SELECT str
      ,SUBSTR(str,rn,1) c
      ,ROW_NUMBER() OVER(PARTITION BY str ORDER BY SUBSTR(str,rn,1)) rn
  FROM words, (SELECT ROWNUM rn FROM DUAL CONNECT BY ROWNUM&lt;=(SELECT MAX(LENGTH(str)) FROM words))
 WHERE rn&lt;=LENGTH(str)
 )
WHERE CONNECT_BY_ISLEAF=1
START WITH rn=1
CONNECT BY str=PRIOR str AND rn = PRIOR rn+1
)
GROUP BY w
ORDER BY cnt DESC;
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: newkid</title>
		<link>http://oraqa.com/2010/06/08/how-to-solve-the-anagrams-puzzle-in-sql/comment-page-1/#comment-271</link>
		<dc:creator>newkid</dc:creator>
		<pubDate>Thu, 24 Jun 2010 21:06:48 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/?p=521#comment-271</guid>
		<description>Well, I might have a misunderstanding of &quot;the same set of letters&quot;. How about this?
&lt;pre&gt; 
SELECT str 
FROM words,
(SELECT DISTINCT REPLACE(SYS_CONNECT_BY_PATH(c,&#039;/&#039;),&#039;/&#039;) w
  FROM (SELECT ROWNUM rn,SUBSTR(:input_str,ROWNUM,1) c FROM DUAL CONNECT BY ROWNUM&lt;=LENGTH(:input_str))
 WHERE LEVEL=LENGTH(:input_str)
CONNECT BY NOCYCLE rn != PRIOR rn  
)
WHERE str=w
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Well, I might have a misunderstanding of &#8220;the same set of letters&#8221;. How about this?</p>
<pre>
SELECT str
FROM words,
(SELECT DISTINCT REPLACE(SYS_CONNECT_BY_PATH(c,'/'),'/') w
  FROM (SELECT ROWNUM rn,SUBSTR(:input_str,ROWNUM,1) c FROM DUAL CONNECT BY ROWNUM&lt;=LENGTH(:input_str))
 WHERE LEVEL=LENGTH(:input_str)
CONNECT BY NOCYCLE rn != PRIOR rn
)
WHERE str=w
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank Zhou</title>
		<link>http://oraqa.com/2010/06/08/how-to-solve-the-anagrams-puzzle-in-sql/comment-page-1/#comment-267</link>
		<dc:creator>Frank Zhou</dc:creator>
		<pubDate>Thu, 24 Jun 2010 19:40:26 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/?p=521#comment-267</guid>
		<description>Hi newkid, 

select TRANSLATE(&#039;angor&#039;,&#039;$&#039;&#124;&#124;&#039;organ&#039;,&#039;$&#039;) from dual
  VS
select TRANSLATE(&#039;aaaaangor&#039;,&#039;$&#039;&#124;&#124;&#039;organ&#039;,&#039;$&#039;) from dual

You will get the same result in both cases, So Transalte function doesn&#039;t work here either.
Also the query&#039;s performance will be slow when using connect by in this case.

Thanks,

Frank</description>
		<content:encoded><![CDATA[<p>Hi newkid, </p>
<p>select TRANSLATE(&#8217;angor&#8217;,'$&#8217;||&#8217;organ&#8217;,'$&#8217;) from dual<br />
  VS<br />
select TRANSLATE(&#8217;aaaaangor&#8217;,'$&#8217;||&#8217;organ&#8217;,'$&#8217;) from dual</p>
<p>You will get the same result in both cases, So Transalte function doesn&#8217;t work here either.<br />
Also the query&#8217;s performance will be slow when using connect by in this case.</p>
<p>Thanks,</p>
<p>Frank</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: newkid</title>
		<link>http://oraqa.com/2010/06/08/how-to-solve-the-anagrams-puzzle-in-sql/comment-page-1/#comment-255</link>
		<dc:creator>newkid</dc:creator>
		<pubDate>Thu, 24 Jun 2010 17:10:49 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/?p=521#comment-255</guid>
		<description>&lt;pre&gt;
SELECT * FROM (
SELECT ANAGRAM_CLASS,lvl,RANK() OVER (ORDER BY lvl DESC) RNK
  FROM (
SELECT SYS_CONNECT_BY_PATH(str,&#039;-&gt;&#039;) ANAGRAM_CLASS,LEVEL lvl
  FROM words 
 CONNECT BY NOCYCLE str&gt;PRIOR str AND TRANSLATE(str,&#039;$&#039;&#124;&#124;PRIOR str,&#039;$&#039;) IS NULL
 )
 )
WHERE RNK=1;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<pre>
SELECT * FROM (
SELECT ANAGRAM_CLASS,lvl,RANK() OVER (ORDER BY lvl DESC) RNK
  FROM (
SELECT SYS_CONNECT_BY_PATH(str,'-&gt;') ANAGRAM_CLASS,LEVEL lvl
  FROM words
 CONNECT BY NOCYCLE str&gt;PRIOR str AND TRANSLATE(str,'$'||PRIOR str,'$') IS NULL
 )
 )
WHERE RNK=1;
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: newkid</title>
		<link>http://oraqa.com/2010/06/08/how-to-solve-the-anagrams-puzzle-in-sql/comment-page-1/#comment-254</link>
		<dc:creator>newkid</dc:creator>
		<pubDate>Thu, 24 Jun 2010 17:05:46 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/?p=521#comment-254</guid>
		<description>SELECT * FROM words WHERE TRANSLATE(str,&#039;$&#039;&#124;&#124;:input_str,&#039;$&#039;) IS NULL;</description>
		<content:encoded><![CDATA[<p>SELECT * FROM words WHERE TRANSLATE(str,&#8217;$'||:input_str,&#8217;$') IS NULL;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

