- From: Andy Seaborne <andy.seaborne@hp.com>
- Date: Fri, 16 Oct 2009 18:51:50 +0100
- To: Ricardo Almeida <ric_gabriel@hotmail.com>
- CC: "public-sparql-dev@w3.org" <public-sparql-dev@w3.org>
Richard Newman wrote: > Hi Ricardo, > >> Is this correct, or the GROUP BY is an extension? > > Aggregates are not part of SPARQL as currently released, so you can't > do GROUP BY. Neither can you do COUNT(?matricula). > > Your implementation might support these, but most don't. > > You also need to drop the angle brackets around your abbreviated > resources — <ex:Pessoa> should be ex:Pessoa. There are a few issues with the syntax: - As Richard says: prefix names don't have <> round them. - You need an extended syntax query engine. - You need to define rdf: - Spaces in URIs are illegal: <http://exemplo.com/ontologia Ex#> - Need "." on the end of triple patterns - ?morada isn't a grouped variable or aggregate so (implementation dependent) you won't get anything for that variable - The GROUP BY is after the "}" PREFIX ex: <http://exemplo.com/ontologia Ex#> SELECT ?nome ?morada COUNT(?matricula) WHERE { ?pId rdf:type ex:Pessoa . ?rId rdf:type ex:Registo . ?pId ex:nome ?nome . ?pId ex:morada ?morada . ?rId ex:temRegisto ?registoId . ?registoId ex:matricula ?matricula . } GROUP BY (?nome) and of course, the RDF data model used to model the SQL needs to agree with the forms above. By the way, the triples ?pId rdf:type ex:Pessoa . ?pId ex:nome ?nome . ?pId ex:morada ?morada . are not connected by any variable to: ?rId rdf:type ex:Registo . ?rId ex:temRegisto ?registoId . ?registoId ex:matricula ?matricula . so it's a cross product. Probably not what you mean. SPARQL validator: http://www.sparql.org/validator.html Tick the "SPARQL extended syntax" box. The current SPARQL working group is plan to define GROUP BY and aggregates and so the exact syntax will change. Andy
Received on Friday, 16 October 2009 17:52:25 UTC