<?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"
	>
<channel>
	<title>Comments on: SQL CHALLENGE</title>
	<atom:link href="http://blog.johnjosephbachir.org/2007/01/19/sql-challenge/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.johnjosephbachir.org/2007/01/19/sql-challenge/</link>
	<description>John Joseph Bachir's blog</description>
	<pubDate>Sat, 30 Aug 2008 01:19:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>By: John</title>
		<link>http://blog.johnjosephbachir.org/2007/01/19/sql-challenge/#comment-112510</link>
		<dc:creator>John</dc:creator>
		<pubDate>Tue, 23 Jan 2007 22:49:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.johnjosephbachir.org/2007/01/19/sql-challenge/#comment-112510</guid>
		<description>Here is something else I came up with, which works properly on some datasets, but when I tried it where every row had the same zip, it came up with 0 rows, not 1. But anyway, it's my current best solution.

&lt;code&gt;SELECT DISTINCT * FROM users u1, users u2 where u1.zipcode != u2.zipcode ORDER BY RAND(UNIX_TIMESTAMP());&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Here is something else I came up with, which works properly on some datasets, but when I tried it where every row had the same zip, it came up with 0 rows, not 1. But anyway, it&#8217;s my current best solution.</p>
<p><code>SELECT DISTINCT * FROM users u1, users u2 where u1.zipcode != u2.zipcode ORDER BY RAND(UNIX_TIMESTAMP());</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://blog.johnjosephbachir.org/2007/01/19/sql-challenge/#comment-111327</link>
		<dc:creator>John</dc:creator>
		<pubDate>Fri, 19 Jan 2007 20:02:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.johnjosephbachir.org/2007/01/19/sql-challenge/#comment-111327</guid>
		<description>Whoah, I just tried it and verified that you are right. Well that makes for a more simple query to start out with. Hmmm</description>
		<content:encoded><![CDATA[<p>Whoah, I just tried it and verified that you are right. Well that makes for a more simple query to start out with. Hmmm</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://blog.johnjosephbachir.org/2007/01/19/sql-challenge/#comment-111326</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Fri, 19 Jan 2007 19:56:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.johnjosephbachir.org/2007/01/19/sql-challenge/#comment-111326</guid>
		<description>Actually no. using having count(zipcode) &#62;=1 means it'll return anything that has at least 1 zipcode in it. It doesn't do much for filtering in this case.</description>
		<content:encoded><![CDATA[<p>Actually no. using having count(zipcode) &gt;=1 means it&#8217;ll return anything that has at least 1 zipcode in it. It doesn&#8217;t do much for filtering in this case.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://blog.johnjosephbachir.org/2007/01/19/sql-challenge/#comment-111207</link>
		<dc:creator>John</dc:creator>
		<pubDate>Fri, 19 Jan 2007 17:18:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.johnjosephbachir.org/2007/01/19/sql-challenge/#comment-111207</guid>
		<description>Hey, thanks for the attempt danny, but that still returns the same row every time :(

and now i am even more confused, because I thought that &lt;code&gt;HAVING count(zipcode)&gt;=1&lt;/code&gt; was the part that squeezed the GROUP BY groups (each zip code cluster) down to 1.</description>
		<content:encoded><![CDATA[<p>Hey, thanks for the attempt danny, but that still returns the same row every time :(</p>
<p>and now i am even more confused, because I thought that <code>HAVING count(zipcode)>=1</code> was the part that squeezed the GROUP BY groups (each zip code cluster) down to 1.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: danny</title>
		<link>http://blog.johnjosephbachir.org/2007/01/19/sql-challenge/#comment-111192</link>
		<dc:creator>danny</dc:creator>
		<pubDate>Fri, 19 Jan 2007 17:06:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.johnjosephbachir.org/2007/01/19/sql-challenge/#comment-111192</guid>
		<description>Try this (tweaked since UNIX_TIMESTAMP() is optional, and WHERE is quicker than HAVING):

SELECT * FROM USERS WHERE zipcode &#62; '' GROUP BY zipcode ORDER BY zipcode, RAND();</description>
		<content:encoded><![CDATA[<p>Try this (tweaked since UNIX_TIMESTAMP() is optional, and WHERE is quicker than HAVING):</p>
<p>SELECT * FROM USERS WHERE zipcode &gt; &#8221; GROUP BY zipcode ORDER BY zipcode, RAND();</p>
]]></content:encoded>
	</item>
</channel>
</rss>
