<?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: Returning the entire row of maximum value for each group (Group-wise Maximum in SQL / MySQL )</title>
	<atom:link href="http://www.logon2.com.au/blog/archive/coding/mysql-coding/groupwise-maximum-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.logon2.com.au/blog/archive/coding/mysql-coding/groupwise-maximum-mysql/</link>
	<description>Better use of the web for everybody</description>
	<lastBuildDate>Fri, 19 Nov 2010 14:41:31 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
	<item>
		<title>By: Thymn</title>
		<link>http://www.logon2.com.au/blog/archive/coding/mysql-coding/groupwise-maximum-mysql/comment-page-1/#comment-64405</link>
		<dc:creator>Thymn</dc:creator>
		<pubDate>Tue, 13 Jul 2010 13:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.logon2.com.au/blog/?p=178#comment-64405</guid>
		<description>It seems that admins can insert arbitrary code into their posts but not anonymous users. See, you can write &lt;b&gt; ... &lt;/b&gt; &lt;b&gt;to make things bold&lt;/b&gt; but not write &lt;script&gt; ... &lt;/script&gt; to write scripts. Or so I think...</description>
		<content:encoded><![CDATA[<p>It seems that admins can insert arbitrary code into their posts but not anonymous users. See, you can write &lt;b&gt; &#8230; &lt;/b&gt; <b>to make things bold</b> but not write &lt;script&gt; &#8230; &lt;/script&gt; to write scripts. Or so I think&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Haugeland</title>
		<link>http://www.logon2.com.au/blog/archive/coding/mysql-coding/groupwise-maximum-mysql/comment-page-1/#comment-64340</link>
		<dc:creator>John Haugeland</dc:creator>
		<pubDate>Sun, 11 Jul 2010 17:01:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.logon2.com.au/blog/?p=178#comment-64340</guid>
		<description>Also, I just noticed that there&#039;s an injection in your blog theme.  If you look at the source for comment six, notice that a less-than which was part of my code quote is making it through unquoted.  (Helpfully, a side effect of this is that one sentence got bolded, so it&#039;s easy to find.)</description>
		<content:encoded><![CDATA[<p>Also, I just noticed that there&#8217;s an injection in your blog theme.  If you look at the source for comment six, notice that a less-than which was part of my code quote is making it through unquoted.  (Helpfully, a side effect of this is that one sentence got bolded, so it&#8217;s easy to find.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Haugeland</title>
		<link>http://www.logon2.com.au/blog/archive/coding/mysql-coding/groupwise-maximum-mysql/comment-page-1/#comment-64269</link>
		<dc:creator>John Haugeland</dc:creator>
		<pubDate>Fri, 09 Jul 2010 13:54:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.logon2.com.au/blog/?p=178#comment-64269</guid>
		<description>&gt; I know my personal WordPress has been hacked but fixing it is not high on my list of priorities. It doesn&#039;t affect my clients.

Good *lord* .  You&#039;re distributing malware and feeding a spammer, knowingly, and you don&#039;t intend to clean it up?

Ugh.

I&#039;m done helping you, sir.  Enjoy being unable to handle extremely simple topics in SQL while giving advice to the public.</description>
		<content:encoded><![CDATA[<p>&gt; I know my personal WordPress has been hacked but fixing it is not high on my list of priorities. It doesn&#8217;t affect my clients.</p>
<p>Good *lord* .  You&#8217;re distributing malware and feeding a spammer, knowingly, and you don&#8217;t intend to clean it up?</p>
<p>Ugh.</p>
<p>I&#8217;m done helping you, sir.  Enjoy being unable to handle extremely simple topics in SQL while giving advice to the public.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Haugeland</title>
		<link>http://www.logon2.com.au/blog/archive/coding/mysql-coding/groupwise-maximum-mysql/comment-page-1/#comment-64268</link>
		<dc:creator>John Haugeland</dc:creator>
		<pubDate>Fri, 09 Jul 2010 13:52:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.logon2.com.au/blog/?p=178#comment-64268</guid>
		<description>&gt; John, the linked and repeated solution in this post doesn’t give extremely incorrect results.

Yes, Tim, it does.  That you haven&#039;t tried it in any other SQL engine, and that you don&#039;t appear to understand what undefined behavior is, is pretty not-compelling.

Try it in Postgres.  Wrong rows.  Try it in Oracle.  Right rows.  Try it in MSSQL.  Wrong rows.

Why?  Because the query is wrong, and the problem just happens not to fire under MySQL or Oracle because of the order their optimizers give.

It&#039;s wrong, Tim, whether you understand it or not.

&gt; You provided an example query (select * from foo as A left join foo as B on A.id = B.id where A.col &lt;B&gt; To be honest when I examine it I don&#039;t see how it would solve this problem

G&#039;lord.</description>
		<content:encoded><![CDATA[<p>&gt; John, the linked and repeated solution in this post doesn’t give extremely incorrect results.</p>
<p>Yes, Tim, it does.  That you haven&#8217;t tried it in any other SQL engine, and that you don&#8217;t appear to understand what undefined behavior is, is pretty not-compelling.</p>
<p>Try it in Postgres.  Wrong rows.  Try it in Oracle.  Right rows.  Try it in MSSQL.  Wrong rows.</p>
<p>Why?  Because the query is wrong, and the problem just happens not to fire under MySQL or Oracle because of the order their optimizers give.</p>
<p>It&#8217;s wrong, Tim, whether you understand it or not.</p>
<p>&gt; You provided an example query (select * from foo as A left join foo as B on A.id = B.id where A.col <b> To be honest when I examine it I don&#8217;t see how it would solve this problem</b></p>
<p>G&#8217;lord.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://www.logon2.com.au/blog/archive/coding/mysql-coding/groupwise-maximum-mysql/comment-page-1/#comment-64259</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Fri, 09 Jul 2010 07:41:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.logon2.com.au/blog/?p=178#comment-64259</guid>
		<description>John, the linked and repeated solution in this post doesn&#039;t give extremely incorrect results.

You provided an example query (select * from foo as A left join foo as B on A.id = B.id where A.col &lt; B.col and B.id is null; ) and I am yet to get it to work. To be honest when I examine it I don&#039;t see how it would solve this problem, but that could just be my inexperience.</description>
		<content:encoded><![CDATA[<p>John, the linked and repeated solution in this post doesn&#8217;t give extremely incorrect results.</p>
<p>You provided an example query (select * from foo as A left join foo as B on A.id = B.id where A.col < B.col and B.id is null; ) and I am yet to get it to work. To be honest when I examine it I don't see how it would solve this problem, but that could just be my inexperience.</p>
</p>]]></content:encoded>
	</item>
	<item>
		<title>By: John Haugeland</title>
		<link>http://www.logon2.com.au/blog/archive/coding/mysql-coding/groupwise-maximum-mysql/comment-page-1/#comment-64252</link>
		<dc:creator>John Haugeland</dc:creator>
		<pubDate>Fri, 09 Jul 2010 05:14:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.logon2.com.au/blog/?p=178#comment-64252</guid>
		<description>Incidentally, your personal blog has been hacked, and currently redirects to a pharmacy website.</description>
		<content:encoded><![CDATA[<p>Incidentally, your personal blog has been hacked, and currently redirects to a pharmacy website.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Haugeland</title>
		<link>http://www.logon2.com.au/blog/archive/coding/mysql-coding/groupwise-maximum-mysql/comment-page-1/#comment-64251</link>
		<dc:creator>John Haugeland</dc:creator>
		<pubDate>Fri, 09 Jul 2010 05:12:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.logon2.com.au/blog/?p=178#comment-64251</guid>
		<description>&quot;I don’t claim to be an SQL expert and I thought the tone of this post was informal enough to make that clear&quot;

Yeah, you&#039;re giving advice in public, then posting it to link sharing sites.  If you want to mince words and suggest that that&#039;s something other than you pretending to be an expert, fine; the point remains, you really should not be giving advice.

&quot;I’m not sure you read the post correctly because the solution (which is very clearly marked) uses neither GROUP BY nor ORDER BY.&quot;

I read the post correctly, sir.  Perhaps you should re-read your own writing.  That criticism was aimed at this verbatim quote:

&quot;“What?” I thought, “That’s the least recent log for task_id 1!”. Then it struck me, “Oh, ORDER BY is performed after GROUP BY. Now what do?” &quot;

What I was trying to point out is that you had reacted to undefined behavior not going the way you expected by guessing, incorrectly, that the undefined behavior was just defined some other way.  (Note that that&#039;s where you leave the topic, too.)

The answer, of course, is something other than to accuse people who provide legitimate technical solutions to your problem of not having read correctly.

&quot;In my opinion, this is non-trivial because it requires a subquery&quot;

That&#039;s ... kind of ridiculous, you know.  That&#039;s like saying &quot;this C++ program is non-trivial because it requires a function.&quot;

I mean come on, that&#039;s about as basic as SQL gets.

What I actually asked you, of course, was &quot;what is trivial to you?&quot;

The phrase &quot;non-trivial&quot; is how a trivial programmer makes themselves feel like any limitation they find in their own skillset reflects something deep and difficult about a language.

Let me remind you: you&#039;re looking for a set of rows with high numbers.  That&#039;s _as_ _simple_ _as_ _production_ _SQL_ _ever_ _gets_.

That&#039;s the *definition* of trivial SQL.

I&#039;ll ask you again.  Please this time focus on what I&#039;m actually asking you.

What, in your mind, constitutes something significantly more trivial than

select * from foo as A left join foo as B on A.id = B.id where A.col &lt; B.col and B.id is null;

I mean, Christ, really?  That&#039;s non-trivial to you?

Please stop attempting to give advice on ridiculously simple topics in SQL in public, regardless of whether you feel your tone means that people shouldn&#039;t be taking you seriously, then explaining why one of the very simplest relational queries possible in the entire language is somehow non-trivial because it&#039;s not just a raw select.

Seriously, the solution you gave is dangerously incorrect; it can give extremely wrong results.

You *need* to not try to explain how to do SQL in the future.  You&#039;re going to screw someone badly.</description>
		<content:encoded><![CDATA[<p>&#8220;I don’t claim to be an SQL expert and I thought the tone of this post was informal enough to make that clear&#8221;</p>
<p>Yeah, you&#8217;re giving advice in public, then posting it to link sharing sites.  If you want to mince words and suggest that that&#8217;s something other than you pretending to be an expert, fine; the point remains, you really should not be giving advice.</p>
<p>&#8220;I’m not sure you read the post correctly because the solution (which is very clearly marked) uses neither GROUP BY nor ORDER BY.&#8221;</p>
<p>I read the post correctly, sir.  Perhaps you should re-read your own writing.  That criticism was aimed at this verbatim quote:</p>
<p>&#8220;“What?” I thought, “That’s the least recent log for task_id 1!”. Then it struck me, “Oh, ORDER BY is performed after GROUP BY. Now what do?” &#8220;</p>
<p>What I was trying to point out is that you had reacted to undefined behavior not going the way you expected by guessing, incorrectly, that the undefined behavior was just defined some other way.  (Note that that&#8217;s where you leave the topic, too.)</p>
<p>The answer, of course, is something other than to accuse people who provide legitimate technical solutions to your problem of not having read correctly.</p>
<p>&#8220;In my opinion, this is non-trivial because it requires a subquery&#8221;</p>
<p>That&#8217;s &#8230; kind of ridiculous, you know.  That&#8217;s like saying &#8220;this C++ program is non-trivial because it requires a function.&#8221;</p>
<p>I mean come on, that&#8217;s about as basic as SQL gets.</p>
<p>What I actually asked you, of course, was &#8220;what is trivial to you?&#8221;</p>
<p>The phrase &#8220;non-trivial&#8221; is how a trivial programmer makes themselves feel like any limitation they find in their own skillset reflects something deep and difficult about a language.</p>
<p>Let me remind you: you&#8217;re looking for a set of rows with high numbers.  That&#8217;s _as_ _simple_ _as_ _production_ _SQL_ _ever_ _gets_.</p>
<p>That&#8217;s the *definition* of trivial SQL.</p>
<p>I&#8217;ll ask you again.  Please this time focus on what I&#8217;m actually asking you.</p>
<p>What, in your mind, constitutes something significantly more trivial than</p>
<p>select * from foo as A left join foo as B on A.id = B.id where A.col &lt; B.col and B.id is null;</p>
<p>I mean, Christ, really?  That&#039;s non-trivial to you?</p>
<p>Please stop attempting to give advice on ridiculously simple topics in SQL in public, regardless of whether you feel your tone means that people shouldn&#039;t be taking you seriously, then explaining why one of the very simplest relational queries possible in the entire language is somehow non-trivial because it&#039;s not just a raw select.</p>
<p>Seriously, the solution you gave is dangerously incorrect; it can give extremely wrong results.</p>
<p>You *need* to not try to explain how to do SQL in the future.  You&#039;re going to screw someone badly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://www.logon2.com.au/blog/archive/coding/mysql-coding/groupwise-maximum-mysql/comment-page-1/#comment-64249</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Fri, 09 Jul 2010 04:10:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.logon2.com.au/blog/?p=178#comment-64249</guid>
		<description>John, I appreciate your feedback and thanks for reading. I don&#039;t claim to be an SQL expert and I thought the tone of this post was informal enough to make that clear. I&#039;m not sure you read the post correctly because the solution (which is very clearly marked) uses neither GROUP BY nor ORDER BY.

I&#039;ll have a look at self-joins on your advice. 

In my opinion, this is non-trivial because it requires a subquery or, as you suggested, a column-wise self join. Such queries don&#039;t fall under the &#039;trivial&#039; category, at least not in my mind.</description>
		<content:encoded><![CDATA[<p>John, I appreciate your feedback and thanks for reading. I don&#8217;t claim to be an SQL expert and I thought the tone of this post was informal enough to make that clear. I&#8217;m not sure you read the post correctly because the solution (which is very clearly marked) uses neither GROUP BY nor ORDER BY.</p>
<p>I&#8217;ll have a look at self-joins on your advice. </p>
<p>In my opinion, this is non-trivial because it requires a subquery or, as you suggested, a column-wise self join. Such queries don&#8217;t fall under the &#8216;trivial&#8217; category, at least not in my mind.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Haugeland</title>
		<link>http://www.logon2.com.au/blog/archive/coding/mysql-coding/groupwise-maximum-mysql/comment-page-1/#comment-64245</link>
		<dc:creator>John Haugeland</dc:creator>
		<pubDate>Fri, 09 Jul 2010 00:50:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.logon2.com.au/blog/?p=178#comment-64245</guid>
		<description>That is an *awful* approach.  Please don&#039;t blog things you figured out in ignorance; people will attempt to follow this advice.  There is no guarantee that your results will be correct, as the order and group by are not defined in execution order with respect to one another.

The appropriate approach is an atomic comparison, which will always give the correct answer regardless of implementation.  One such approach - the default in this situation - is a column-wise self join comparing left to right such that right&#039;s value is null (that is, &quot;give me all the rows such that for the comparison there is no valid right side,&quot;) which will always give the appropriate highest value (and in far better time besides.)

Hilariously, the *correct* answer is also provided on the MySQL page you linked.  It&#039;s just that when you get bad advice from the MySQL manual, it&#039;s usually MySQL specific.

Please leave the SQL advice to people who understand SQL in the future.

Thanks.

(Groupwise maximums are non-trivial SQL now?  Good lord, what&#039;s trivial to you?)</description>
		<content:encoded><![CDATA[<p>That is an *awful* approach.  Please don&#8217;t blog things you figured out in ignorance; people will attempt to follow this advice.  There is no guarantee that your results will be correct, as the order and group by are not defined in execution order with respect to one another.</p>
<p>The appropriate approach is an atomic comparison, which will always give the correct answer regardless of implementation.  One such approach &#8211; the default in this situation &#8211; is a column-wise self join comparing left to right such that right&#8217;s value is null (that is, &#8220;give me all the rows such that for the comparison there is no valid right side,&#8221;) which will always give the appropriate highest value (and in far better time besides.)</p>
<p>Hilariously, the *correct* answer is also provided on the MySQL page you linked.  It&#8217;s just that when you get bad advice from the MySQL manual, it&#8217;s usually MySQL specific.</p>
<p>Please leave the SQL advice to people who understand SQL in the future.</p>
<p>Thanks.</p>
<p>(Groupwise maximums are non-trivial SQL now?  Good lord, what&#8217;s trivial to you?)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

