Thanks Lee and Paul,
finally I think the unexpected results were (1) due to the shuffled labeValues and (2) due to my WHERE clause. The order is as expected in the query below.

SELECT DISTINCT ?labelValue FROM :graphA FROM :graphB
WHERE {    ?post :contains :givenTag .
 ?post :contains ?tag .
 ?tag :label ?labelValue .
 ?tag :updated ?date   // before: ?post :created ?date
 }
ORDER BY DESC (?date) ?labelValue
LIMIT 10

Not sure yet why this works and the former does not. Maybe the prob is in my data, I will have to re-check this.

Regards,
Mirko



Am 12.09.2009 um 05:27 schrieb Paul Gearon:

I'm late on this, I know, but all the same...

On Mon, Aug 31, 2009 at 6:06 AM, Lee Feigenbaum <[email protected]> wrote:
SELECT DISTINCT should be unrelated to ORDER BY, which in turn should be unrelated to the graphs that comprise the default graph in your RDF dataset.
If you are seeing a problem, perhaps you should contact the
maintainers/supporters of your specific SPARQL implementation.

Lee

SELECT DISTINCT will usually reorder data (depending on the
implementation), but ORDER BY will always override this. In this case,
it looks like the ordering on labelValue is being shuffled with SELECT
DISTINCT, which is perfectly fine, since there is no ordering on it
(only on dates).

I would recommend updating the query to order by labelValue after
date, thereby fixing the result:

SELECT ?labelValue FROM :graphA FROM :graphB
WHERE {    ?post :contains :givenTag .
 ?post :contains ?tag .
 ?tag :label ?labelValue .
 ?post :created ?date
 }
ORDER BY DESC (?date) ?labelValue
LIMIT 10

Regards,
Paul

Mirko wrote:

Hi,
I wonder how to solve this. I have the following query:

SELECT ?labelValue FROM :graphA FROM :graphB
WHERE {    ?post :contains :givenTag .
 ?post :contains ?tag .
 ?tag :label ?labelValue .
 ?post :created ?date
 }
ORDER BY DESC (?date)
LIMIT 10

Now, I would like to have only distinct ?labelValues as results.
Unfortunately, in my case SELECT DISTINCT messes up the order when selecting
from several graphs.

How could I make the results (?labelValue) of the above query distinct
while keeping the order?

Thanks,
Mirko






Reply via email to