On Mon, Jan 12, 2015 at 4:13 PM, Igor Tandetnik <i...@tandetnik.org> wrote:

> On 1/12/2015 9:53 AM, Dominique Devienne wrote:
>
>> My little brain has no idea how the "a;b:c/c,d" came about from the input
>> rows, so I don't find it logical at all myself...
>>
>
> Simple, really. For each ('x', '@') row, string_agg adds '@x' to the
> resulting string (except the separator is omitted for the very first row
> encountered, in this case ('a', ',') ). Thanks to DISTINCT, the second
> occurrence of ('c', '/') is skipped , so you only have '/c' appear once. On
> the other hand, both '/c' and ':c' appear, indicating that DISTINCT works
> on both parameters, not just the first.


OK, lets follow that logic:
1) a-comma yield just a (first row special case)
2) b-semi-colon yields semi-colon b
3) c-slash (both of them, collapsed by DISTINCT) yields slash c
4) c-colon yields colon c
5) d comma yields comma d

so that's "a;b/c:c,d", not "a;b:c/c,d"


>  But I fail to see how the delimiter come from in "a;b:c/c,d", especially
>> why they are "out of order" vs the value-order. FWIW. --DD
>>
>
> Aggregate functions don't guarantee any particular order of visiting rows
> within the group. What is this "value-order" of which you speak? I'm not
> familiar with the term.


Just order of the "value" column in Clemens example. Not value in general.
OK, the no-order-guarantee would explain the difference with my result
above. I think I see it now. Thanks, Igor. --DD
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to