Finalize bi-15 query
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
+PREFIX sn: <http://www.ldbc.eu/ldbc_socialnet/1.0/data/>
+PREFIX snvoc: <http://www.ldbc.eu/ldbc_socialnet/1.0/vocabulary/>
+PREFIX sntag: <http://www.ldbc.eu/ldbc_socialnet/1.0/tag/>
+PREFIX foaf: <http://xmlns.com/foaf/0.1/>
+PREFIX dbpedia: <http://dbpedia.org/resource/>
+PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
+
+SELECT ?person ?avgFriendCount (COUNT(?friend) AS ?friendCount)
+WHERE
+{
+ {
+ SELECT ?countryName (FLOOR(COUNT(?friend) / COUNT(DISTINCT ?person)) AS ?avgFriendCount)
+ WHERE
+ {
+ BIND( "Germany" AS ?countryName )
+ ?person a snvoc:Person .
+ ?person snvoc:isLocatedIn/snvoc:isPartOf/foaf:name ?countryName .
+ ?person snvoc:knows/snvoc:hasPerson ?friend .
+ ?friend a snvoc:Person .
+ ?friend snvoc:isLocatedIn/snvoc:isPartOf/foaf:name ?countryName
+ }
+ GROUP BY ?countryName
+ }
+ ?person a snvoc:Person .
+ ?person snvoc:isLocatedIn/snvoc:isPartOf/foaf:name ?countryName .
+ ?person snvoc:knows/snvoc:hasPerson ?friend .
+ ?friend a snvoc:Person .
+ ?friend snvoc:isLocatedIn/snvoc:isPartOf/foaf:name ?countryName
+}
+GROUP BY ?person ?avgFriendCount
+HAVING(?friendCount = ?avgFriendCount)
+ORDER BY ?person
+LIMIT 100
