W3C home > Mailing lists > Public > public-sparql-dev@w3.org > January to March 2009

Minimum/Maximum values

From: Jon Crump <jjcrump@myuw.net>
Date: Fri, 27 Feb 2009 14:00:01 -0800 (PST)
To: public-sparql-dev@w3.org
Message-ID: <Pine.LNX.4.64.0902271314170.7086@cicero12.myuw.net>
Dear all,

Another naive question from the peanut gallery about date arithmetic (or 
arithmetic in general)

Given a graph:

:bob a :Person;
     :byear "1962".
:carol a :Person;
     :byear "1963".
:ted a :Person;
     :byear "1964".
:alice a :Person;
     :byear "1965".

:Smiths a :Family;
     :children :bob, :carol, :ted, :alice.


How to find the minimum and maximum birthyears represented in family 
Smith? I've gotten this far:

SELECT ?date
WHERE{ ?family :children ?child .
     ?child :byear ?date .
     OPTIONAL{{
         {?earlier :byear ?edate . FILTER (?edate < ?date)}
         {?later :byear ?ldate . FILTER (?ldate > ?date)}
     }}
     FILTER (!bound(?later))
}

But this binds both earliest and latest to ?date. To make the comparison 
in the filters I have to compare ?edate and ?ldate to a common variable 
?date, but what I'd like my query to return is the earliest date bound to 
?start and the latest bound to ?end.

Something obvious here that I'm missing. Suggestions?

Thanks,
Jon
Received on Friday, 27 February 2009 22:00:40 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 27 February 2009 22:00:41 GMT