Discussion:
SPARQL - sort by multiple columns
Oancea Daniel
2010-05-19 16:29:36 UTC
Permalink
Hello,

It's possible to sort the SPARQL-DL result by multiple columns?

To be more precisely, imagine that I have an ontology with the some
individuals representing company employees.

At the interrogation:

SELECT ?first ?last
FROM test

WHERE
{
?name test:hasFirstName ?first .
?name test:hasLastName ?last .
}

I got the list of employees. If I'm using ORDER BY (?first) or ORDER BY
(?last) I'm able to order the result by first name respectively by last
name.
How can I use the both in the same SPARQL- DL interrogation?
I've been trying use ORDER BY (?first && ?last) but I didn't get the right
answer.

Therefore, Is a way to use the ORDER BY SPARQL clause to take in
consideration multiple columns?

Thanks
-Daniel
--
________
Note: If the reader of this message is not the intended recipient, or an
employee or agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited. If you have received
this communication in error, please notify us immediately by replying to the
message and deleting it from your computer. Thank you.
Blazej Bulka
2010-05-19 16:44:17 UTC
Permalink
Daniel,

You can specify multiple variables in the ORDER BY clause (as
specified by the SPARQL standard specification [1]).

Therefore, your query could be written as:

SELECT ?first ?last
FROM test

WHERE
{
?name test:hasFirstName ?first .
?name test:hasLastName ?last .
}
ORDER BY ?first ?last


You can also use ASC or DESC modifiers, as shown in the examples in
referenced SPARQL standard specs.

I hope it helps,

Blazej Bulka <***@clarkparsia.com>

[1] http://www.w3.org/TR/rdf-sparql-query/#modOrderBy
Post by Oancea Daniel
Hello,
It's possible to sort the SPARQL-DL result by multiple columns?
To be more precisely, imagine that I have an ontology with the some
individuals representing company employees.
SELECT  ?first ?last
FROM test
WHERE
{
?name test:hasFirstName ?first .
?name test:hasLastName ?last .
}
I got the list of employees. If I'm using ORDER BY (?first) or ORDER BY
(?last) I'm able to order the result by first name respectively by last
name.
How can I use the both in the same SPARQL- DL interrogation?
I've been trying use ORDER BY (?first && ?last)  but I didn't get the right
answer.
Therefore, Is a way to use the ORDER BY SPARQL clause to take in
consideration multiple columns?
Thanks
-Daniel
--
________
Note:  If the reader of this message is not the intended recipient, or an
employee or agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited. If you have received
this communication in error, please notify us immediately by replying to the
message and deleting it from your computer. Thank you.
_______________________________________________
Pellet-users mailing list
http://lists.owldl.com/mailman/listinfo/pellet-users
_______________________________________________
Sponsored by Clark & Parsia, LLC http://clarkparsia.com/
_______________________________________________
Pellet-users mailing list
Pellet-***@lists.owldl.com
http://lists.owldl.com/mailman/listinfo/pellet-users
_______________________________________________

Sponsored by Clark & Parsia, LLC http://clarkparsia.com/

Loading...