Really fix complex query 4
@@ -9,22 +9,30 @@ PREFIX dbpedia: <http://dbpedia.org/resource/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
SELECT
- (?tagname AS ?tagName)
- (count(*) AS ?postCount)
+ ?tagName
+ (COUNT(*) AS ?postCount)
WHERE {
- ?post a snvoc:Post . ?post snvoc:hasCreator ?fr .
- ?post snvoc:hasTag ?tag . ?tag foaf:name ?tagname .
- ?post snvoc:creationDate ?date . sn:pers$Person snvoc:knows ?fr .
- FILTER (?date >= $Date0 && ?date <= $Date0 + "P$DurationD"^^xsd:duration) .
- FILTER ( NOT EXISTS {
- sn:pers$Person snvoc:knows ?fr2 .
+ BIND( xsd:dateTime("$startDate+00:00") AS ?startDate ) .
+ BIND( ?startDate + "P$durationD"^^xsd:duration AS ?endDate ) .
+ ?rootPerson snvoc:id "26388279068083"^^xsd:long .
+ ?rootPerson ((snvoc:knows/snvoc:hasPerson)|^(snvoc:knows/snvoc:hasPerson)) ?fr .
+ ?post a snvoc:Post .
+ ?post snvoc:hasCreator ?fr .
+ ?post snvoc:hasTag ?tag .
+ ?tag foaf:name ?tagName .
+ ?post snvoc:creationDate ?creationDate .
+ BIND( ?creationDate >= ?startDate AS ?bigger ) .
+ BIND( ?creationDate < ?endDate AS ?less ) .
+ FILTER (?creationDate >= ?startDate && ?creationDate <= ?endDate ) .
+ FILTER NOT EXISTS {
+ ?rootPerson ((snvoc:knows/snvoc:hasPerson)|^(snvoc:knows/snvoc:hasPerson)) ?fr2 .
?post2 snvoc:hasCreator ?fr2 .
?post2 a snvoc:Post .
?post2 snvoc:hasTag ?tag .
- ?post2 snvoc:creationDate ?date2 .
- FILTER (?date2 < $Date0)
- })
+ ?post2 snvoc:creationDate ?creationDate2 .
+ FILTER (?creationDate2 < ?startDate)
}
-GROUP BY ?tagname
-ORDER BY desc(?cnt) ?tagname
-limit 10
+}
+GROUP BY ?tagName
+ORDER BY DESC(?postCount) ?tagName
+LIMIT 10
