This HTML5 document contains 40 embedded RDF statements represented using HTML+Microdata notation.

The embedded RDF content will be recognized by any processor of HTML5 Microdata.

PrefixNamespace IRI
n15http://vos.openlinksw.com/dataspace/owiki/wiki/VOS/VirtSPARQLArithmeticExamplesCollection/sioc.
n12http://bit.ly/
dctermshttp://purl.org/dc/terms/
atomhttp://atomowl.org/ontologies/atomrdf#
foafhttp://xmlns.com/foaf/0.1/
n10http://vos.openlinksw.com/dataspace/services/wiki/
oplhttp://www.openlinksw.com/schema/attribution#
n2http://vos.openlinksw.com/dataspace/owiki/wiki/VOS/
n13http://docs.openlinksw.com/virtuoso/rdfsparql.
dchttp://purl.org/dc/elements/1.1/
n20http://vos.openlinksw.com/dataspace/dav#
rdfshttp://www.w3.org/2000/01/rdf-schema#
n9http://rdfs.org/sioc/services#
siocthttp://rdfs.org/sioc/types#
n5http://vos.openlinksw.com/dataspace/person/dav#
n11http://vos.openlinksw.com/dataspace/owiki/wiki/
rdfhttp://www.w3.org/1999/02/22-rdf-syntax-ns#
n7http://vos.openlinksw.com/dataspace/owiki#
xsdhhttp://www.w3.org/2001/XMLSchema#
n18http://vos.openlinksw.com/dataspace/person/owiki#
siochttp://rdfs.org/sioc/ns#
Subject Item
n5:this
foaf:made
n2:VirtSPARQLArithmeticExamplesCollection
Subject Item
n20:this
sioc:creator_of
n2:VirtSPARQLArithmeticExamplesCollection
Subject Item
n10:item
n9:services_of
n2:VirtSPARQLArithmeticExamplesCollection
Subject Item
n7:this
sioc:creator_of
n2:VirtSPARQLArithmeticExamplesCollection
Subject Item
n11:VOS
sioc:container_of
n2:VirtSPARQLArithmeticExamplesCollection
atom:entry
n2:VirtSPARQLArithmeticExamplesCollection
atom:contains
n2:VirtSPARQLArithmeticExamplesCollection
Subject Item
n2:VirtSPARQLArithmeticExamplesCollection
rdf:type
sioct:Comment atom:Entry
dcterms:created
2017-06-13T05:39:35.098589
dcterms:modified
2017-06-29T07:39:57.443677
rdfs:label
VirtSPARQLArithmeticExamplesCollection
foaf:maker
n5:this n18:this
dc:title
VirtSPARQLArithmeticExamplesCollection
opl:isDescribedUsing
n15:rdf
sioc:has_creator
n7:this n20:this
sioc:content
%META:TOPICPARENT{name="VirtTipsAndTricksGuide"}% ---+SPARQL Arithmetic Examples Collection %TOC% This guide contains Virtuoso SPARQL Arithmetic Examples Collection of queries which you can run against any SPARQL endpoint. ---++Example Find death age of musicians <verbatim> SELECT ?s ?genre ?died ?born ( bif:datediff( 'year', xsd:dateTime( str(?born) ), xsd:dateTime( str(?died) ) ) ) AS ?age WHERE { { SELECT DISTINCT ?s ?genre ?died ?born FROM <http://dbpedia.org> WHERE { ?s a <http://dbpedia.org/ontology/MusicalArtist> ; <http://dbpedia.org/ontology/genre> ?genre ; <http://dbpedia.org/ontology/deathDate> ?died ; <http://dbpedia.org/ontology/birthDate> ?born . } LIMIT 20 } } </verbatim> * [[http://bit.ly/U8TKW0][View the SPARQL Query Definition via SPARQL Protocol URL]] * [[http://bit.ly/U8SXnY][View the SPARQL Query Results via SPARQL Protocol URL]] ---++Example Find death age of musicians with validating the born and died dates <verbatim> SELECT ?person ?genre ?died ?born ( if ( ( datatype (?born) in (xsd:dateTime, xsd:date) ) and ( datatype (?died) in (xsd:dateTime, xsd:date) ), bif:datediff( 'year', xsd:dateTime( str(?born) ), xsd:dateTime( str(?died) ) ), "error" ) ) AS ?age WHERE { { SELECT DISTINCT ?person ?genre ?died ?born FROM <http://dbpedia.org> WHERE { ?person a <http://dbpedia.org/ontology/MusicalArtist> ; <http://dbpedia.org/ontology/genre> ?genre ; <http://dbpedia.org/ontology/deathDate> ?died ; <http://dbpedia.org/ontology/birthDate> ?born . } ORDER BY DESC ( <LONG::IRI_RANK> (?person) ) LIMIT 10 } } </verbatim> * [[http://bit.ly/14PqPZ4][View the SPARQL Query Definition via SPARQL Protocol URL]] * [[http://bit.ly/U8TS7X][View the SPARQL Query Results via SPARQL Protocol URL]] ---++Example Find death age of musicians with calculated rank based on person <verbatim> SELECT DISTINCT ?person ?plabel ?genre ?glabel ?died ?born ( <LONG::IRI_RANK> (?person) ) as ?rank ( if ( ( datatype (?born) in (xsd:dateTime, xsd:date) ) and ( datatype (?died) in (xsd:dateTime, xsd:date) ), bif:datediff( 'year', xsd:dateTime( str(?born) ), xsd:dateTime( str(?died) ) ), "error" ) ) AS ?age WHERE { { SELECT DISTINCT ?person ?plabel ?genre ?glabel ?died ?born FROM <http://dbpedia.org> WHERE { ?person a <http://dbpedia.org/ontology/MusicalArtist> ; <http://dbpedia.org/ontology/genre> ?genre ; <http://dbpedia.org/ontology/deathDate> ?died ; rdfs:label ?plabel ; <http://dbpedia.org/ontology/birthDate> ?born . ?genre rdfs:label ?glabel . FILTER (lang(?plabel) = "en") FILTER (lang(?glabel) = "en") } ORDER BY DESC ( <LONG::IRI_RANK> (?person) ) LIMIT 10 } } </verbatim> * [[http://bit.ly/U8UmL3][View the SPARQL Query Definition via SPARQL Protocol URL]] * [[http://bit.ly/WX5Tfh][View the SPARQL Query Results via SPARQL Protocol URL]] ---++Example Find average death age of musicians by genre <verbatim> SELECT ?genre, (avg(?age)) AS ?avg WHERE { { SELECT distinct ?genre ?person (bif:datediff( 'year', xsd:dateTime( str(?born) ), xsd:dateTime( str(?died)))) as ?age WHERE { { SELECT distinct ?person ?genre ?died ?born FROM <http://dbpedia.org> WHERE { ?person a <http://dbpedia.org/ontology/MusicalArtist> ; <http://dbpedia.org/ontology/genre> ?genre ; <http://dbpedia.org/ontology/deathDate> ?died ; <http://dbpedia.org/ontology/birthDate> ?born . FILTER ( datatype (?born) IN (xsd:dateTime, xsd:date) ) FILTER ( datatype (?died) IN (xsd:dateTime, xsd:date) ) } } } } } GROUP BY (?genre) LIMIT 10 </verbatim> * [[http://bit.ly/YTrrJW][View the SPARQL Query Definition via SPARQL Protocol URL]] * [[http://bit.ly/V28S99][View the SPARQL Query Results via SPARQL Protocol URL]] ---++Example Show people data with Entity Rank, Grouping and Pretty Labels <verbatim> SELECT DISTINCT ?person str(?plabel) ?genre str(?glabel) ?died ?born ( <LONG::IRI_RANK> (?person) ) as ?rank ( if ( ( datatype (?born) in (xsd:dateTime, xsd:date) ) and ( datatype (?died) in (xsd:dateTime, xsd:date) ), bif:datediff('year',xsd:dateTime(str(?born)),xsd:dateTime(str(?died))), "error" ) ) AS ?age WHERE { { SELECT DISTINCT ?person ?plabel ?genre ?glabel ?died ?born FROM <http://dbpedia.org> WHERE { ?person a <http://dbpedia.org/ontology/MusicalArtist> ; <http://dbpedia.org/ontology/genre> ?genre ; <http://dbpedia.org/ontology/deathDate> ?died ; rdfs:label ?plabel ; <http://dbpedia.org/ontology/birthDate> ?born . ?genre rdfs:label ?glabel . FILTER ( lang(?plabel) = "en" ) FILTER ( lang(?glabel) = "en" ) } ORDER BY DESC ( <LONG::IRI_RANK> (?person) ) LIMIT 10 } } </verbatim> * [[http://bit.ly/WX6n4R][View the SPARQL Query Definition via SPARQL Protocol URL]] * [[http://bit.ly/Y6ahWO][View the SPARQL Query Results via SPARQL Protocol URL]] ---++Related * [[VirtTipsAndTricksGuide][Virtuoso Tips and Tricks Collection]] * [[http://docs.openlinksw.com/virtuoso/rdfsparql.html][Virtuoso Documentation]]
sioc:id
0c522d70358e91d951f43e3311c62a3a
sioc:link
n2:VirtSPARQLArithmeticExamplesCollection
sioc:has_container
n11:VOS
n9:has_services
n10:item
atom:title
VirtSPARQLArithmeticExamplesCollection
sioc:links_to
n12:WX6n4R n13:html n12:Y6ahWO n12:YTrrJW n12:V28S99 n12:U8UmL3 n12:WX5Tfh n12:14PqPZ4 n12:U8TS7X n12:U8TKW0 n12:U8SXnY
atom:source
n11:VOS
atom:author
n5:this
atom:published
2017-06-13T05:39:35Z
atom:updated
2017-06-29T07:39:57Z
sioc:topic
n11:VOS