On 11/11/15 1:09 PM, Francesco Balzu wrote: > 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=0 > * The 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 Store > * I 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 > <http://localhost:8890/conductor/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.
Do you have a live SPARQL endpoint? It's hard to understand your problem as currently outlined. Does the following make a difference: ## I changed: ## ?ride km4c:hasAVMRecord ?avmr to: ## ?ride km4c:hasAVMRecord ?avmr2 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 ?avmr2. } GROUP BY ?ride ORDER BY DESC (?avmrLast) LIMIT 15 -- Regards, Kingsley Idehen Founder & CEO OpenLink Software Company Web: http://www.openlinksw.com Personal Weblog 1: http://kidehen.blogspot.com Personal Weblog 2: http://www.openlinksw.com/blog/~kidehen Twitter Profile: https://twitter.com/kidehen Google+ Profile: https://plus.google.com/+KingsleyIdehen/about LinkedIn Profile: http://www.linkedin.com/in/kidehen Personal WebID: http://kingsley.idehen.net/dataspace/person/kidehen#this
smime.p7s
Description: S/MIME Cryptographic Signature
------------------------------------------------------------------------------
_______________________________________________ Virtuoso-users mailing list Virtuoso-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/virtuoso-users