W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > July to September 2010

Re: GROUP_CONCAT DISTINCT

From: Andy Seaborne <andy.seaborne@epimorphics.com>
Date: Mon, 20 Sep 2010 10:44:56 +0100
Message-ID: <4C972D18.9000907@epimorphics.com>
To: Lee Feigenbaum <lee@thefigtrees.net>
CC: Axel Polleres <axel.polleres@deri.org>, SPARQL Working Group <public-rdf-dawg@w3.org>
ARQ implements GROUP_CONCAT(DISTINCT)

	Andy

On 20/09/10 00:46, Lee Feigenbaum wrote:
> Glitter implements that, though I need to update the syntax for SEPARATOR.
>
> Lee
>
> On 9/19/2010 7:17 PM, Axel Polleres wrote:
>> It seems DISTINCT might be quite important for GROUP_CONCAT ...
>> I was just playing with the following use case
>>
>>
>> Data:
>> @prefix ex:<http://example.org/> .
>> @prefix foaf:<http://xmlns.com/foaf/0.1/> .
>>
>> ex:alice a foaf:Person; foaf:name "Alice Wonderland";
>> foaf:nick "Alice", "The real Alice".
>>
>> ex:bob a foaf:Person;
>> foaf:name "Robert Doe", "Robert Charles Doe", "Robert C. Doe";
>> foaf:nick "Bob","Bobby","RobC","BobDoe".
>>
>> ex:charles a foaf:Person;
>> foaf:name "Charles Charles";
>> foaf:nick "Charlie" .
>> =============
>>
>> My query should do the following:
>> pick one sample name per person, plus a concatenated list of nicknames
>>
>> query, first version:
>>
>> =============
>>
>> PREFIX foaf:<http://xmlns.com/foaf/0.1/>
>> SELECT ( SAMPLE(?N) as ?Name)
>> ( GROUP_CONCAT(?M; SEPARATOR = ",") AS ?Nicknames )
>> WHERE { ?P a foaf:Person ;
>> foaf:name ?N ;
>> foaf:nick ?M . }
>> GROUP BY ?P
>>
>> =============
>>
>> doesn't work, since the nicknames appear repeated... I suppose this is
>> where I'd need DISTINCT, but I couldn't get that
>> following version running yet with any implementation:
>>
>> =============
>> PREFIX foaf:<http://xmlns.com/foaf/0.1/>
>> SELECT ( SAMPLE(?N) as ?Name)
>> ( GROUP_CONCAT( DISTINCT ?M; SEPARATOR = ",") AS ?Nicknames )
>> WHERE { ?P a foaf:Person ;
>> foaf:name ?N ;
>> foaf:nick ?M . }
>> GROUP BY ?P
>>
>> =============
>>
>> My expected result for the latter query was something like:
>> --------------------------------------------------------------------------------------------
>>
>> | Name | Nicknames |
>> ============================================================================================
>>
>> | "Robert C. Doe" | "BobDoe,RobC,Bobby,Bob" |
>> | "Alice Wonderland" | "The real Alice,Alice" |
>> | "Charles Charles" | "Charlie" |
>> --------------------------------------------------------------------------------------------
>>
>>
>> Does anybody have that implemented/running yet?
>>
>> best,
>> Axel
>>
>
Received on Monday, 20 September 2010 09:45:37 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:15:43 GMT