0

I'm going through the AnzoGraph tutorial. I have 2 questions: 1) They often use desc, e.g. desc(?sum) in the Order By or other parts of the query. I'm not familiar with this and didn't find much help in the SPARQL documentation. What does desc do and why is it needed? 2) Sometimes, when I would expect to see a number in the output I see an alphanumeric string. E.g., in the query:

SELECT ?location ?kind ?name ?list_date (((?selldate - ?list_date)) as ?sale_age)
FROM <tickit>
WHERE {
  ?sale <saletime> ?selldate .
  ?sale <eventid> ?event .
  ?listing <eventid> ?event .
  ?listing <listtime> ?list_date .
  ?event <eventname> ?name .
  ?event <venueid> ?venue .
  ?event <catid> ?cat .
  ?cat <catname> ?kind .
  ?venue <venuename> ?location .
}
ORDER BY desc(?selldate) desc(?list_date) ?location ?kind ?name

I expect to see ?sale_age as an an integer but it is displayed as alphanumerics such as: P1DT1H50M.

  • As these two questions aren’t closely related, it would be best to ask them separately – which then also allows you to provide a descriptive title (containing what your question is, not what it’s about). – Stefan - brox IT-Solutions Sep 06 '22 at 21:10
  • 2
    `desc` is descending order, default in SPARQL is ascending, the keyword `asc` can be omitted in that case. Why is clear, you want e.g. something from high to low, or vice versa. See also https://www.w3.org/TR/sparql11-query/#modOrderBy – UninformedUser Sep 07 '22 at 13:57
  • 2
    `sale_age` is a duration, that's from XML schema the duration notation, see https://www.w3.org/TR/xmlschema-2/#duration . You get this result because the native SPARQL datatype for data/time is basically `xsd:dateTime`. And for that datatype, also being from XML schema, the arithmetic operation of subtraction is supposed to be a duration. – UninformedUser Sep 07 '22 at 14:01
  • Thanks! That answers both questions. – Michael DeBellis Sep 08 '22 at 18:21

0 Answers0