I am trying to get list of all the authors who have had more than 3 piece of work - DBpedia Sparql

前端 未结 2 795
后悔当初
后悔当初 2021-01-27 04:36

I am trying to get list of all the authors who have had 3 or more piece of work done (in DBpedia).

my example can be run on : http://dbpedia.org/sparql

base co

相关标签:
2条回答
  • 2021-01-27 05:25

    Using HAVING is correct, but there is a limitation in SPARQL with indirectly referring to aggregates.

    This one works:

    SELECT (count(?work) as ?tw) ?author
    WHERE
    {
      ?work dbo:author ?author.
    }
    GROUP BY ?author
    HAVING (count(?work) > 3)
    
    0 讨论(0)
  • 2021-01-27 05:27

    HAVING (?tw > 3) is correct SPARQL. HAVING filters after assignments due to SELECT, so ?tw is visible, and before projection.

    (prefix ((dbo: <http://purl.org/dc/elements/1.1/>))
        (project (?tw ?author)
          (filter (> ?tw 3)
            (extend ((?tw ?.0))
              (group (?author) ((?.0 (count ?work)))
                (bgp (triple ?work dbo:author ?author)))))))
    

    where ?.0 is the assignment of count.

    0 讨论(0)
提交回复
热议问题