<?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: Simulating First/Last aggregate functions in MySQL</title>
	<atom:link href="http://www.zonalivre.org/2009/10/12/simulating-firstlast-aggregate-functions-in-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zonalivre.org/2009/10/12/simulating-firstlast-aggregate-functions-in-mysql/</link>
	<description></description>
	<lastBuildDate>Sat, 17 Apr 2010 14:31:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Joao</title>
		<link>http://www.zonalivre.org/2009/10/12/simulating-firstlast-aggregate-functions-in-mysql/comment-page-1/#comment-23</link>
		<dc:creator>Joao</dc:creator>
		<pubDate>Sat, 17 Apr 2010 14:31:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.zonalivre.org/?p=3#comment-23</guid>
		<description>I&#039;ve just tried your approach and indeed it&#039;s more efficient. Thanks for sharing!</description>
		<content:encoded><![CDATA[<p>I&#8217;ve just tried your approach and indeed it&#8217;s more efficient. Thanks for sharing!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: webmaster</title>
		<link>http://www.zonalivre.org/2009/10/12/simulating-firstlast-aggregate-functions-in-mysql/comment-page-1/#comment-22</link>
		<dc:creator>webmaster</dc:creator>
		<pubDate>Sat, 17 Apr 2010 08:12:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.zonalivre.org/?p=3#comment-22</guid>
		<description>You can get results like that but you are sorting (order-ing) in calculated colums which will not be efficient with large tables.
Here is a solution that is simple elegant and uses efficiently indexes etc. 
The text behid the link is specifically only about this solution of a FIRST and LAST aggragating functions wiht GROUP BY in MySQL:
http://topwebguy.com/first-and-last-in-mysql-a-working-solution/</description>
		<content:encoded><![CDATA[<p>You can get results like that but you are sorting (order-ing) in calculated colums which will not be efficient with large tables.<br />
Here is a solution that is simple elegant and uses efficiently indexes etc.<br />
The text behid the link is specifically only about this solution of a FIRST and LAST aggragating functions wiht GROUP BY in MySQL:<br />
<a href="http://topwebguy.com/first-and-last-in-mysql-a-working-solution/" rel="nofollow">http://topwebguy.com/first-and-last-in-mysql-a-working-solution/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joao</title>
		<link>http://www.zonalivre.org/2009/10/12/simulating-firstlast-aggregate-functions-in-mysql/comment-page-1/#comment-13</link>
		<dc:creator>Joao</dc:creator>
		<pubDate>Sat, 28 Nov 2009 14:28:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.zonalivre.org/?p=3#comment-13</guid>
		<description>But how do you guarantee sort order ?  That&#039;s the bit I couldn&#039;t figure out. Does &quot;datetime as `desc`&quot; somehow make it happen, or is it something that can be implemented inside the UDF ?</description>
		<content:encoded><![CDATA[<p>But how do you guarantee sort order ?  That&#8217;s the bit I couldn&#8217;t figure out. Does &#8220;datetime as `desc`&#8221; somehow make it happen, or is it something that can be implemented inside the UDF ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arnold Daniels</title>
		<link>http://www.zonalivre.org/2009/10/12/simulating-firstlast-aggregate-functions-in-mysql/comment-page-1/#comment-12</link>
		<dc:creator>Arnold Daniels</dc:creator>
		<pubDate>Sat, 28 Nov 2009 13:56:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.zonalivre.org/?p=3#comment-12</guid>
		<description>Nice little hack :).

You could do this with a MySQL UDF though. Like the above function you need to pass the field with the value as well as the field to order by.

SELECT agg_last(close, datetime AS `desc`) FROM ...
</description>
		<content:encoded><![CDATA[<p>Nice little hack <img src='http://www.zonalivre.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>You could do this with a MySQL UDF though. Like the above function you need to pass the field with the value as well as the field to order by.</p>
<p>SELECT agg_last(close, datetime AS `desc`) FROM &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joao</title>
		<link>http://www.zonalivre.org/2009/10/12/simulating-firstlast-aggregate-functions-in-mysql/comment-page-1/#comment-6</link>
		<dc:creator>Joao</dc:creator>
		<pubDate>Fri, 20 Nov 2009 12:23:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.zonalivre.org/?p=3#comment-6</guid>
		<description>Not sure you can do this as a function using the same underlying logic.

My first approach was to create an aggregate UDF, but that didn&#039;t work because you can&#039;t guarantee the order of data going into the udf.</description>
		<content:encoded><![CDATA[<p>Not sure you can do this as a function using the same underlying logic.</p>
<p>My first approach was to create an aggregate UDF, but that didn&#8217;t work because you can&#8217;t guarantee the order of data going into the udf.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephen</title>
		<link>http://www.zonalivre.org/2009/10/12/simulating-firstlast-aggregate-functions-in-mysql/comment-page-1/#comment-5</link>
		<dc:creator>stephen</dc:creator>
		<pubDate>Thu, 19 Nov 2009 17:58:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.zonalivre.org/?p=3#comment-5</guid>
		<description>I am trying to turn this into a function, but it won&#039;t work. Please, correct me.

DELIMITER $$

DROP FUNCTION IF EXISTS `test`.`last`$$
CREATE FUNCTION  `test`.`last`(f1 varchar(12),f2 varchar(12)) RETURNS varchar(12) CHARSET latin1
return substring_index(group_concat(f1 order by f2 desc),&#039;,&#039;,1);

 $$

DELIMITER ;</description>
		<content:encoded><![CDATA[<p>I am trying to turn this into a function, but it won&#8217;t work. Please, correct me.</p>
<p>DELIMITER $$</p>
<p>DROP FUNCTION IF EXISTS `test`.`last`$$<br />
CREATE FUNCTION  `test`.`last`(f1 varchar(12),f2 varchar(12)) RETURNS varchar(12) CHARSET latin1<br />
return substring_index(group_concat(f1 order by f2 desc),&#8217;,',1);</p>
<p> $$</p>
<p>DELIMITER ;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joao</title>
		<link>http://www.zonalivre.org/2009/10/12/simulating-firstlast-aggregate-functions-in-mysql/comment-page-1/#comment-3</link>
		<dc:creator>Joao</dc:creator>
		<pubDate>Mon, 26 Oct 2009 10:35:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.zonalivre.org/?p=3#comment-3</guid>
		<description>Sure. When you&#039;re done send me the link so I can see it.</description>
		<content:encoded><![CDATA[<p>Sure. When you&#8217;re done send me the link so I can see it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Polprav</title>
		<link>http://www.zonalivre.org/2009/10/12/simulating-firstlast-aggregate-functions-in-mysql/comment-page-1/#comment-2</link>
		<dc:creator>Polprav</dc:creator>
		<pubDate>Thu, 22 Oct 2009 21:30:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.zonalivre.org/?p=3#comment-2</guid>
		<description>Hello from Russia!
Can I quote a post in your blog with the link to you?</description>
		<content:encoded><![CDATA[<p>Hello from Russia!<br />
Can I quote a post in your blog with the link to you?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
