(I had forgotten to create a new thread and ended up re-hijacking this
one.  So I'm starting a new thread here... Please in the future, don't
use Reply to start a new thread.)

Kevin, a simple solution is to use the following aggregate:

SELECT ?person1 ?person2 count(?forum)
 WHERE
 {     ?person1 sioc:follows ?forum .
       ?person2 sioc:follows ?forum .
       FILTER (?person1 != ?person2) .
 } GROUP BY ?person1 ?person2

Of course, this will get the results twice, once for person1 and again
for person2.  But this is the nature of any pairwise comparison with
SPARQL.

-- Scott

On 5/14/10 1:12 PM, Kevin wrote:
> Scott,
>
> Thanks again. The simple scenario you've outlined I understand. What I
> was going for is:
>
> Show me a list of users who have more than 1 forum they follow in
> common.
> If I get that, then how many forums do they share in common (count)
>
> Kevin
>
> On May 14, 10:29 am, Scott Henninger <[email protected]>
> wrote:
>> Kevin; Unless you need to use aggregate in your query, sub-selects are 
>> rarely needed.  The key to understanding SPARQL is that it is a mirror of 
>> RDF.  Each triple represents an edge in a graph.  Using variables creates a 
>> graph pattern that is matched against the RDF graph.
>> If what you want are the people following the same forum, you can visualize 
>> this as a forum as the central node of a graph and finding all people 
>> following that forum.  Then filter out all cases where it's the same person.
>> SELECT ?person1 ?forum ?person2
>> WHERE
>> {     ?person1 sioc:follows ?forum .
>>       ?person2 sioc:follows ?forum .
>>       FILTER (?person1 != ?person2) .
>> }
>> To get a count of the number of people following a forum use the count 
>> aggregate, grouping by the forum matches:
>> SELECT ?forum count(*)
>> WHERE
>> {     ?person1 sioc:follows ?forum .
>>       ?person2 sioc:follows ?forum .
>>        FILTER (?person1 != ?person2) .
>> } GROUP BY ?forum
>> -- Scott

-- 
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include TopBraid Composer,
TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en

Reply via email to