Hi,

I'm writing a custom aggregate function whose result depends on the sort order 
of a subselect. It isn't clear whether this a good idea and the documentation 
on group_concat(X) seems to suggest that the order that rows are processed by 
an aggregate function is not guaranteed ("The order of the concatenated 
elements is arbitrary." -- http://www.sqlite.org/lang_aggfunc.html).

Given something like this:

SELECT group_concat(name)
FROM (SELECT * FROM table ORDER BY name)
GROUP BY some_id;

I understood the documentation of group_concat() as meaning that even though 
there is an ORDER BY in the subselect, the order of the concatenated names is 
not guaranteed. If that is the case, it seems logical that the restriction is 
only there because the order in which the aggregate function processes each row 
is arbitrary. Does anyone know if this is true or is it safe to assume that the 
aggregate will access each row in order?

Thank you,
Emmanuel MacCaull
Software Developer
Research In Motion Limited

---------------------------------------------------------------------
This transmission (including any attachments) may contain confidential 
information, privileged material (including material protected by the 
solicitor-client or other applicable privileges), or constitute non-public 
information. Any use of this information by anyone other than the intended 
recipient is prohibited. If you have received this transmission in error, 
please immediately reply to the sender and delete this information from your 
system. Use, dissemination, distribution, or reproduction of this transmission 
by unintended recipients is not authorized and may be unlawful.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to