Non-deterministically, a subselect can be used rather than SAMPLE overall:

SELECT ?name ?age
{ { SELECT * { ?A :name ?name } LIMIT 1 }
  ?A :age ?age
}

If you add GROUPing and the suggestions here to the subselect, the overall results are deterministic, even though the order within the results isn't.

        Andy

On 25/04/18 07:08, Lorenz Buehmann wrote:
Making it deterministic can be done via MIN/MAX instead of SAMPLE.


On 24.04.2018 14:26, Osma Suominen wrote:
Hi Laura!

If LIMIT is not applicable (e.g. you want to query for many similar
resources in one query), you can also consider using SAMPLE (with a
GROUP BY).

If you want to make the choice deterministic, you can use LIMIT
together with ORDER BY.

-Osma

Laura Morales kirjoitti 24.04.2018 klo 15:23:
Yeah I'd prefer one over the other, but I don't think there is any
simple way to distinguish them, I think multiple values are just
supposed to be unordered.
I'll end up using LIMIT or DISTINCT. Thank you.
Sent: Tuesday, April 24, 2018 at 2:12 PM
From: ajs6f <[email protected]>
To: [email protected]
Subject: Re: [sparql] Return only one property of many with the same
name
Do you care about which one?

If not, just use the LIMIT keyword to get only one. Otherwise, it's
going to depend on which one you want and how you want to distinguish
them.

ajs6f

On Apr 24, 2018, at 5:54 AM, Laura Morales <[email protected]> wrote:

If I have this node

:Alice :name "Alice", "Alice Smith" ;
:age 25 .

how can I return *only one* of the ":name" properties with SPARQL?
For example return ("Alice", 25)


Reply via email to