---++ODS eCRM GoodRelations SPARQL Reference
%TOC%
The following collection offers GoodRelations SPARQL queries:
---+++Companies With Support Cases That Have Not Placed At Least One Order
In other words get all Evaluators with Closed Support cases who haven't become Customers.
PREFIX ecrm:
PREFIX gr:
PREFIX foaf:
SELECT ?name ?case
FROM
WHERE
{
?comp a gr:BusinessEntity .
?comp foaf:name ?name .
?comp ecrm:is_company_of ?case .
?case a ecrm:Case.
OPTIONAL{?comp ecrm:has_order ?order .
?order a ecrm:Order }.
FILTER (!bound (?order)).
}
* View Query Results [[http://demo.openlinksw.com/sparql?default-graph-uri=&should-sponge=&query=PREFIX++ecrm%3A+%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fschemas%2Fecrm%23%3E%0D%0APREFIX++gr%3A+%3Chttp%3A%2F%2Fpurl.org%2Fgoodrelations%2Fv1%23%3E%0D%0APREFIX+foaf%3A+%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%0D%0ASELECT+%3Fname+%3Fcase%0D%0AFROM+%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fecrm%3E%0D%0AWHERE%0D%0A++%7B%0D%0A++++%3Fcomp+a+gr%3ABusinessEntity+.%0D%0A++++%3Fcomp+foaf%3Aname+%3Fname+.%0D%0A++++%3Fcomp+ecrm%3Ais_company_of+%3Fcase+.%0D%0A++++%3Fcase+a+ecrm%3ACase.%0D%0A++++OPTIONAL%7B%3Fcomp+ecrm%3Ahas_order+%3Forder+.%0D%0A+++++++++++++++++++++++++%3Forder+a+ecrm%3AOrder+%7D.%0D%0A++++FILTER+%28%21bound+%28%3Forder%29%29.%0D%0A++%7D&format=text%2Fhtml&debug=on][(via SPARQL Protocol URL)]]
* View Query Results [[http://demo.openlinksw.com/view/?format=application%2Frdf%2Bxml&maxrows=50&query=%0APREFIX%20%20ecrm%3A%20%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fschemas%2Fecrm%23%3E%0APREFIX%20%20gr%3A%20%3Chttp%3A%2F%2Fpurl.org%2Fgoodrelations%2Fv1%23%3E%0APREFIX%20foaf%3A%20%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%0ASELECT%20%3Fname%20%3Fcase%0AFROM%20%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fecrm%3E%0AWHERE%0A%20%20%7B%0A%20%20%20%20%3Fcomp%20a%20gr%3ABusinessEntity%20.%0A%20%20%20%20%3Fcomp%20foaf%3Aname%20%3Fname%20.%0A%20%20%20%20%3Fcomp%20ecrm%3Ais_company_of%20%3Fcase%20.%0A%20%20%20%20%3Fcase%20a%20ecrm%3ACase.%0A%20%20%20%20OPTIONAL%7B%3Fcomp%20ecrm%3Ahas_order%20%3Forder%20.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Forder%20a%20ecrm%3AOrder%20%7D.%0A%20%20%20%20FILTER%20(%21bound%20(%3Forder)).%0A%20%20%7D&endpoint=/sparql&maxrows=50&default-graph-uri=][(via iSPARQL Results URL)]]
* View Query Editor [[http://demo.openlinksw.com/isparql/?query=PREFIX%20%20ecrm%3A%20%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fschemas%2Fecrm%23%3E%0APREFIX%20%20gr%3A%20%3Chttp%3A%2F%2Fpurl.org%2Fgoodrelations%2Fv1%23%3E%0APREFIX%20foaf%3A%20%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%0ASELECT%20%3Fname%20%3Fcase%0AFROM%20%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fecrm%3E%0AWHERE%0A%20%20%7B%0A%20%20%20%20%3Fcomp%20a%20gr%3ABusinessEntity%20.%0A%20%20%20%20%3Fcomp%20foaf%3Aname%20%3Fname%20.%0A%20%20%20%20%3Fcomp%20ecrm%3Ais_company_of%20%3Fcase%20.%0A%20%20%20%20%3Fcase%20a%20ecrm%3ACase.%0A%20%20%20%20OPTIONAL%7B%3Fcomp%20ecrm%3Ahas_order%20%3Forder%20.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Forder%20a%20ecrm%3AOrder%20%7D.%0A%20%20%20%20FILTER%20(%21bound%20(%3Forder)).%0A%20%20%7D&endpoint=/sparql&maxrows=50&default-graph-uri=][(via iSPARQL Visual Query Editor URL)]]
---+++Evaluators Who's Company Has Not Placed At Least One Order
In other words get all Evaluators that haven't become customers.
PREFIX ecrm:
PREFIX gr:
PREFIX foaf:
SELECT ?name
FROM
WHERE
{
?comp a gr:BusinessEntity .
?comp foaf:name ?name .
OPTIONAL {?comp ecrm:has_order ?order .
?order a ecrm:Order }.
FILTER (!bound (?order)).
}
* View Query Results [[http://demo.openlinksw.com/sparql?default-graph-uri=&should-sponge=&query=PREFIX+ecrm%3A+%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fschemas%2Fecrm%23%3E%0D%0APREFIX+gr%3A+%3Chttp%3A%2F%2Fpurl.org%2Fgoodrelations%2Fv1%23%3E%0D%0APREFIX+foaf%3A+%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%0D%0ASELECT+%3Fname%0D%0AFROM+%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fecrm%3E%0D%0AWHERE%0D%0A++%7B%0D%0A++++%3Fcomp+a+gr%3ABusinessEntity+.%0D%0A++++%3Fcomp+foaf%3Aname+%3Fname+.%0D%0A++++OPTIONAL+%7B%3Fcomp+ecrm%3Ahas_order+%3Forder+.%0D%0A++++++++++++++++++++++++++%3Forder+a+ecrm%3AOrder+%7D.%0D%0A++++FILTER+%28%21bound+%28%3Forder%29%29.%0D%0A++%7D&format=text%2Fhtml&debug=on][(via SPARQL Protocol URL)]]
* View Query Results [[http://demo.openlinksw.com/view/?format=application%2Frdf%2Bxml&maxrows=50&query=%0APREFIX%20ecrm%3A%20%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fschemas%2Fecrm%23%3E%0APREFIX%20gr%3A%20%3Chttp%3A%2F%2Fpurl.org%2Fgoodrelations%2Fv1%23%3E%0APREFIX%20foaf%3A%20%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%0ASELECT%20%3Fname%0AFROM%20%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fecrm%3E%0AWHERE%0A%20%20%7B%0A%20%20%20%20%3Fcomp%20a%20gr%3ABusinessEntity%20.%0A%20%20%20%20%3Fcomp%20foaf%3Aname%20%3Fname%20.%0A%20%20%20%20OPTIONAL%20%7B%3Fcomp%20ecrm%3Ahas_order%20%3Forder%20.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Forder%20a%20ecrm%3AOrder%20%7D.%0A%20%20%20%20FILTER%20(%21bound%20(%3Forder)).%0A%20%20%7D&endpoint=/sparql&maxrows=50&default-graph-uri=][(via iSPARQL Results URL)]]
* View Query Editor [[http://demo.openlinksw.com/isparql/?query=PREFIX%20ecrm%3A%20%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fschemas%2Fecrm%23%3E%0APREFIX%20gr%3A%20%3Chttp%3A%2F%2Fpurl.org%2Fgoodrelations%2Fv1%23%3E%0APREFIX%20foaf%3A%20%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%0ASELECT%20%3Fname%0AFROM%20%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fecrm%3E%0AWHERE%0A%20%20%7B%0A%20%20%20%20%3Fcomp%20a%20gr%3ABusinessEntity%20.%0A%20%20%20%20%3Fcomp%20foaf%3Aname%20%3Fname%20.%0A%20%20%20%20OPTIONAL%20%7B%3Fcomp%20ecrm%3Ahas_order%20%3Forder%20.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Forder%20a%20ecrm%3AOrder%20%7D.%0A%20%20%20%20FILTER%20(%21bound%20(%3Forder)).%0A%20%20%7D&endpoint=/sparql&maxrows=50&default-graph-uri=][(via iSPARQL Visual Query Editor URL)]]
---+++Orders By Geo Location
PREFIX ecrm:
PREFIX gr:
SELECT *
FROM
WHERE
{
?order a gr:Offering .
?order ecrm:shipCountry ?country .
FILTER (?country LIKE '%Russia%').
}
* View Query Results [[http://demo.openlinksw.com/sparql?default-graph-uri=&should-sponge=&query=PREFIX+ecrm%3A+%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fschemas%2Fecrm%23%3E%0D%0APREFIX+gr%3A+%3Chttp%3A%2F%2Fpurl.org%2Fgoodrelations%2Fv1%23%3E%0D%0ASELECT+*%0D%0AFROM+%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fecrm%3E%0D%0AWHERE+%0D%0A++%7B%0D%0A++++%3Forder+a+gr%3AOffering+.%0D%0A++++%3Forder+ecrm%3AshipCountry+%3Fcountry+.%0D%0A++++FILTER+%28%3Fcountry+LIKE+%27%25Russia%25%27%29.%0D%0A++%7D&format=text%2Fhtml&debug=on][(via SPARQL Protocol URL)]]
* View Query Results [[http://demo.openlinksw.com/view/?format=application%2Frdf%2Bxml&maxrows=50&query=%0APREFIX%20ecrm%3A%20%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fschemas%2Fecrm%23%3E%0APREFIX%20gr%3A%20%3Chttp%3A%2F%2Fpurl.org%2Fgoodrelations%2Fv1%23%3E%0ASELECT%20*%0AFROM%20%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fecrm%3E%0AWHERE%20%0A%20%20%7B%0A%20%20%20%20%3Forder%20a%20gr%3AOffering%20.%0A%20%20%20%20%3Forder%20ecrm%3AshipCountry%20%3Fcountry%20.%0A%20%20%20%20FILTER%20(%3Fcountry%20LIKE%20%27%25Russia%25%27).%0A%20%20%7D&endpoint=/sparql&maxrows=50&default-graph-uri=][(via iSPARQL Results URL)]]
* View Query Editor [[http://demo.openlinksw.com/isparql/?query=PREFIX%20ecrm%3A%20%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fschemas%2Fecrm%23%3E%0APREFIX%20gr%3A%20%3Chttp%3A%2F%2Fpurl.org%2Fgoodrelations%2Fv1%23%3E%0ASELECT%20*%0AFROM%20%3Chttp%3A%2F%2Fdemo.openlinksw.com%2Fecrm%3E%0AWHERE%20%0A%20%20%7B%0A%20%20%20%20%3Forder%20a%20gr%3AOffering%20.%0A%20%20%20%20%3Forder%20ecrm%3AshipCountry%20%3Fcountry%20.%0A%20%20%20%20FILTER%20(%3Fcountry%20LIKE%20%27%25Russia%25%27).%0A%20%20%7D&endpoint=/sparql&maxrows=50&default-graph-uri=][(via iSPARQL Visual Query Editor URL)]]
---+++References
* [[http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/ECRMRef][eCRM SPARQL SIOC Reference]]
* [[http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/GoodRelationsRef][Virtuoso GoodRelations SPARQL Reference Collection]]
* [[http://www.heppnetz.de/ontologies/goodrelations/v1][GoodRelations Ontology]]
* [[http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/VirtRDFViewODSeCRM][eCRM Linked Data Views]]