<docbook><section><title>ODSeCRMGoodRelationsRef</title><bridgehead class="http://www.w3.org/1999/xhtml:h2">ODS eCRM <ulink url="GoodRelations">GoodRelations</ulink> SPARQL Reference</bridgehead>
<para>The following collection offers <ulink url="GoodRelations">GoodRelations</ulink> SPARQL queries:</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">Companies With Support Cases That Have Not Placed At Least One Order</bridgehead>
<para>In other words get all Evaluators with Closed Support cases who haven&#39;t become Customers.</para>
<programlisting>PREFIX  ecrm: &lt;http://demo.openlinksw.com/schemas/ecrm#&gt;
PREFIX  gr: &lt;http://purl.org/goodrelations/v1#&gt;
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?name ?case
FROM &lt;http://demo.openlinksw.com/ecrm&gt;
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)).
  }
</programlisting><para> </para>
<itemizedlist mark="bullet" spacing="compact"><listitem>View Query Results <ulink url="http://demo.openlinksw.com/sparql?default-graph-uri=&amp;should-sponge=&amp;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&amp;format=text%2Fhtml&amp;debug=on">(via SPARQL Protocol URL)</ulink> </listitem>
<listitem>View Query Results <ulink url="http://demo.openlinksw.com/view/?format=application%2Frdf%2Bxml&amp;maxrows=50&amp;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&amp;endpoint=/sparql&amp;maxrows=50&amp;default-graph-uri=">(via iSPARQL Results URL)</ulink> </listitem>
<listitem>View Query Editor <ulink url="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&amp;endpoint=/sparql&amp;maxrows=50&amp;default-graph-uri=">(via iSPARQL Visual Query Editor URL)</ulink></listitem>
</itemizedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3">Evaluators Who&#39;s Company Has Not Placed At Least One Order</bridgehead>
<para>In other words get all Evaluators that haven&#39;t become customers.</para>
<programlisting>PREFIX ecrm: &lt;http://demo.openlinksw.com/schemas/ecrm#&gt;
PREFIX gr: &lt;http://purl.org/goodrelations/v1#&gt;
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT ?name
FROM &lt;http://demo.openlinksw.com/ecrm&gt;
WHERE
  {
    ?comp a gr:BusinessEntity .
    ?comp foaf:name ?name .
    OPTIONAL {?comp ecrm:has_order ?order .
                          ?order a ecrm:Order }.
    FILTER (!bound (?order)).
  }
</programlisting><para> </para>
<itemizedlist mark="bullet" spacing="compact"><listitem>View Query Results <ulink url="http://demo.openlinksw.com/sparql?default-graph-uri=&amp;should-sponge=&amp;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&amp;format=text%2Fhtml&amp;debug=on">(via SPARQL Protocol URL)</ulink> </listitem>
<listitem>View Query Results <ulink url="http://demo.openlinksw.com/view/?format=application%2Frdf%2Bxml&amp;maxrows=50&amp;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&amp;endpoint=/sparql&amp;maxrows=50&amp;default-graph-uri=">(via iSPARQL Results URL)</ulink> </listitem>
<listitem>View Query Editor <ulink url="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&amp;endpoint=/sparql&amp;maxrows=50&amp;default-graph-uri=">(via iSPARQL Visual Query Editor URL)</ulink></listitem>
</itemizedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3">Orders By Geo Location</bridgehead>
<programlisting>PREFIX ecrm: &lt;http://demo.openlinksw.com/schemas/ecrm#&gt;
PREFIX gr: &lt;http://purl.org/goodrelations/v1#&gt;
SELECT *
FROM &lt;http://demo.openlinksw.com/ecrm&gt;
WHERE 
  {
    ?order a gr:Offering .
    ?order ecrm:shipCountry ?country .
    FILTER (?country LIKE &#39;%Russia%&#39;).
  }
</programlisting><itemizedlist mark="bullet" spacing="compact"><listitem>View Query Results <ulink url="http://demo.openlinksw.com/sparql?default-graph-uri=&amp;should-sponge=&amp;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&amp;format=text%2Fhtml&amp;debug=on">(via SPARQL Protocol URL)</ulink> </listitem>
<listitem>View Query Results <ulink url="http://demo.openlinksw.com/view/?format=application%2Frdf%2Bxml&amp;maxrows=50&amp;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&amp;endpoint=/sparql&amp;maxrows=50&amp;default-graph-uri=">(via iSPARQL Results URL)</ulink> </listitem>
<listitem>View Query Editor <ulink url="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&amp;endpoint=/sparql&amp;maxrows=50&amp;default-graph-uri=">(via iSPARQL Visual Query Editor URL)</ulink></listitem>
</itemizedlist><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">References</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/ECRMRef">eCRM SPARQL SIOC Reference</ulink> </listitem>
<listitem><ulink url="http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/GoodRelationsRef">Virtuoso GoodRelations SPARQL Reference Collection</ulink> </listitem>
<listitem><ulink url="http://www.heppnetz.de/ontologies/goodrelations/v1">GoodRelations Ontology</ulink> </listitem>
<listitem><ulink url="http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/VirtRDFViewODSeCRM">eCRM Linked Data Views</ulink> </listitem>
</itemizedlist></section></docbook>