Re: GROUP_CONCAT DISTINCT

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 UTC