<?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 Impossible Combination Puzzle in SQL</title>
	<atom:link href="http://oraqa.com/2008/02/05/how-to-solve-the-impossible-combination-puzzle-in-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://oraqa.com/2008/02/05/how-to-solve-the-impossible-combination-puzzle-in-sql/</link>
	<description>Oracle Question and Answer</description>
	<lastBuildDate>Tue, 06 Jul 2010 14:28:12 -0600</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/2008/02/05/how-to-solve-the-impossible-combination-puzzle-in-sql/comment-page-1/#comment-280</link>
		<dc:creator>newkid</dc:creator>
		<pubDate>Fri, 25 Jun 2010 14:50:43 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/2008/02/05/how-to-solve-the-impossible-combination-puzzle-in-sql/#comment-280</guid>
		<description>11GR2:
&lt;pre&gt;
WITH coins AS (
  SELECT 1 cents FROM DUAL
  UNION ALL SELECT 5 cents FROM DUAL
  UNION ALL SELECT 10 cents FROM DUAL
  UNION ALL SELECT 25 cents FROM DUAL
  UNION ALL SELECT 50 cents FROM DUAL
  )
,t(c1,c5,c10,c25,c50,cents,total_val) AS (
SELECT DECODE(c.cents,1,1,0)
      ,DECODE(c.cents,5,1,0)          
      ,DECODE(c.cents,10,1,0)          
      ,DECODE(c.cents,25,1,0)          
      ,DECODE(c.cents,50,1,0)          
      ,cents 
      ,cents 
  FROM coins c
UNION ALL
SELECT c1 + DECODE(c.cents,1,1,0)
      ,c5 + DECODE(c.cents,5,1,0)          
      ,c10+ DECODE(c.cents,10,1,0)          
      ,c25+ DECODE(c.cents,25,1,0)          
      ,c50+ DECODE(c.cents,50,1,0)          
      ,c.cents
      ,t.total_val + c.cents
  FROM t, coins c
WHERE t.total_val + c.cents&lt;=100 AND t.cents&lt;=c.cents
)
,t2 AS (
SELECT DISTINCT c1+c5+c10+c25+c50 cnt FROM t WHERE total_val=100
)
SELECT MIN(rn) 
 FROM (SELECT ROWNUM+1 rn FROM DUAL CONNECT BY ROWNUM&lt;100
       )
WHERE NOT EXISTS (SELECT 1 FROM t2 WHERE cnt=rn);
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>11GR2:</p>
<pre>
WITH coins AS (
  SELECT 1 cents FROM DUAL
  UNION ALL SELECT 5 cents FROM DUAL
  UNION ALL SELECT 10 cents FROM DUAL
  UNION ALL SELECT 25 cents FROM DUAL
  UNION ALL SELECT 50 cents FROM DUAL
  )
,t(c1,c5,c10,c25,c50,cents,total_val) AS (
SELECT DECODE(c.cents,1,1,0)
      ,DECODE(c.cents,5,1,0)
      ,DECODE(c.cents,10,1,0)
      ,DECODE(c.cents,25,1,0)
      ,DECODE(c.cents,50,1,0)
      ,cents
      ,cents
  FROM coins c
UNION ALL
SELECT c1 + DECODE(c.cents,1,1,0)
      ,c5 + DECODE(c.cents,5,1,0)
      ,c10+ DECODE(c.cents,10,1,0)
      ,c25+ DECODE(c.cents,25,1,0)
      ,c50+ DECODE(c.cents,50,1,0)
      ,c.cents
      ,t.total_val + c.cents
  FROM t, coins c
WHERE t.total_val + c.cents&lt;=100 AND t.cents&lt;=c.cents
)
,t2 AS (
SELECT DISTINCT c1+c5+c10+c25+c50 cnt FROM t WHERE total_val=100
)
SELECT MIN(rn)
 FROM (SELECT ROWNUM+1 rn FROM DUAL CONNECT BY ROWNUM&lt;100
       )
WHERE NOT EXISTS (SELECT 1 FROM t2 WHERE cnt=rn);
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>
