Perhaps something like:
prefix ex: <http://example.org/ontology#>
SELECT ?title (sample(?b) as ?subject) WHERE {
?uri ex:title ?title ;
ex:subject ?b ;
} GROUP BY ?uri ?title
On Thu, May 4, 2017 at 7:15 AM, Laura Morales <[email protected]> wrote:
> Let's say I have this simple model for a dataset of books
>
> <a-book>
> title "only 1 title" .
> topic "some topic", "another topic", "many topics" .
>
> There is one title, but several topics. I want to retrieve a list of
> books, together with their title and only one topic (any one of them is
> OK). So what I want is a list of results like this
>
> <book-1> title "title"
> <book-1> topic "some topic"
> <book-2> title "the title"
> <book-2> topic "random topic"
> ...
>
> Is there any (simple) way to do this with SPARQL?
>