Hello,

Ok, may be the reason is really that I am running a bit old Virtuoso, Virtuoso 5 ver:0.9849.
The script is attached.

Thank you for the help!

Best Regards,
Silvia

Ivan Mikhailov wrote:
Silvia,

How old is your version of Virtuoso? HAVING syntax is supported not from
the very beginning in SPARQL/BI, it's relatively new thing. Before that
that required a combination of a sub-SELECT with grouping and WHERE in
the outer select, something like

SPARQL SELECT ?s ?total
WHERE { {
        SELECT ?s SUM(?books) as ?total
        FROM <http://mygraph.person>
        WHERE
          {
            ?s  <http://mygraph/person/books> ?books .
          } }
    FILTER (?total > 2) }


Best Regards,

Ivan Mikhailov
OpenLink Virtuoso
http://virtuoso.openlinksw.com



SPARQL insert in graph <http://mygraph.person>
{
<http://mygraph/person/1>  <http://mygraph/person/email>  "[email protected]".
<http://mygraph/person/1>  <http://mygraph/person/email>  "[email protected]".
<http://mygraph/person/1>  <http://mygraph/person/name> "Alice".
<http://mygraph/person/2>  <http://mygraph/person/name> "Bob". 
<http://mygraph/person/2>  <http://mygraph/person/age> 
'10'^^<http://www.w3.org/2001/XMLSchema#integer> . 
<http://mygraph/person/1>  <http://mygraph/person/age> 
'20'^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://mygraph/person/1>  <http://mygraph/person/books> 
'20'^^<http://www.w3.org/2001/XMLSchema#integer> . 
<http://mygraph/person/1>  <http://mygraph/person/books> 
'2'^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://mygraph/person/2>  <http://mygraph/person/books> 
'12'^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://mygraph/person/11>  <http://mygraph/person/name> "Anika".
<http://mygraph/person/11>  <http://mygraph/person/books> 
'32'^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://mygraph/person/11>  <http://mygraph/person/books> 
'20'^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://mygraph/person/21>  <http://mygraph/person/books> 50 .
<http://mygraph/person/31>  <http://mygraph/person/books> 500. 
};


sparql
select ?s SUM(?books)
FROM <http://mygraph.person>
WHERE {?s  <http://mygraph/person/books> ?books . }
having (sum(?books) > 2);

Reply via email to