- From: Andy Seaborne <andy.seaborne@talis.com>
- Date: Mon, 16 Nov 2009 20:14:04 +0000
- To: Steve Harris <steve.harris@garlik.com>
- CC: "public-rdf-dawg@w3.org Group" <public-rdf-dawg@w3.org>
On 15/11/2009 18:12, Steve Harris wrote:
> It's a little unfortunate because we might have to return an error from
> a MIN (etc.) over an empty multiset, which isn't ideal for some usecases:
>
> data:
>
> :alice a :Salesperson ;
> :sales [
> :date "2009-11-14" ;
> :volume 12 ;
> ] , [
> :date "2009-11-14" ;
> :volume 9 ;
> ] .
> :bob a :Salesperson ;
> :sales [
> :date "2009-11-14" ;
> :volume 8 ;
> ] .
> :carol a :Salesperson .
>
> query:
>
> SELECT ?x (MAX(?sales) AS ?bestDay)
> WHERE {
> ?x a :Salesperson .
> OPTIONAL {
> ?x :sales [
> :volume ?sales ;
> ]
> }
> }
> GROUP BY ?x
>
> results:
>
> ?x = :alice, ?bestDay = 12
> ?x = :bob, ?bestDay = 8
> [no row for :carol because we can't return "unbound"/null from MAX(?sales)]
>
Would this work?
SELECT ?x ( TRY(MAX(?sales), -1) AS ?bestDay)
or other choice of marker for no value.
Andy
Received on Monday, 16 November 2009 20:14:19 UTC