Excuse me if I submit again the same question, but it is important to me to 
know where I am mistaken.
I have a problem with the MAX aggregate function in SPARQL. I provide the data 
and the query that generates the wrong (according to me) result. The query is 
slightly different from the one that I sent last time: this recreates the 
issue, in my pc.

The two graphs needed are at 
https://www.dropbox.com/sh/fl1yzk98bg2de1r/AABoMoXSHYWZXqgi96I7URbca?dl=0The
 file avm_dump_25K.ttl contains the graph 
<http://localhost:8890/avm_quadStore_25K>, whereas the file 
Autobus_lotto_metropolitano_f.ttl contains the graph <
http://www.disit.org/km4city/resource/Autobus/5_Lotto_Metropolitano_Firenze_f>I 
load the two graphs into Virtuoso Quad StoreI run the following query:  
         

     PREFIX km4c:<http://www.disit.org/km4city/schema#>
     PREFIX foaf:<http://xmlns.com/foaf/0.1/>
     PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
  
     SELECT ?ride (MAX(?avmr) AS ?avmrLast)
     WHERE{
        ?bs rdf:type km4c:BusStop.
        ?bs foaf:name "PIAZZA DI SAN MARCO".
        ?bsf km4c:isForecastOfBusStop ?bs.
        ?bsf km4c:isForecastOfAVM ?avmr.
        ?ride km4c:hasAVMRecord ?avmr.
         }
     GROUP BY ?ride ORDER BY DESC (?avmrLast) LIMIT 15


and I obtain as result


ride
    avmrLast
  
  
    http://www.disit.org/km4city/resource/4900006
    iri_id_0_with_no_name_entry

If I don't use MAX function, that is if I run


     PREFIX km4c:<http://www.disit.org/km4city/schema#>
     PREFIX foaf:<http://xmlns.com/foaf/0.1/>
     PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
  
     SELECT ?ride (?avmr AS ?avmrLast)
     WHERE{
        ?bs rdf:type km4c:BusStop.
        ?bs foaf:name "PIAZZA DI SAN MARCO".
        ?bsf km4c:isForecastOfBusStop ?bs.
        ?bsf km4c:isForecastOfAVM ?avmr.
        ?ride km4c:hasAVMRecord ?avmr.
         }
     GROUP BY ?ride ORDER BY DESC (?avmrLast) LIMIT 15

I obtain 
ride
    avmrLast
  
  
    http://www.disit.org/km4city/resource/4900006
    
http://www.disit.org/km4city/resource/2015-12-11T10:10:02.3500006+02:00+4900006

In
 this case the dataset is small and I get only one row as result, but in
 general it may be much bigger and so I would need to use max function.

Thanks for your precious help.
Best regards,
Francesco Balzano.                                        
------------------------------------------------------------------------------
_______________________________________________
Virtuoso-users mailing list
Virtuoso-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/virtuoso-users

Reply via email to