Customers

Text
PREFIX foaf:       <http://xmlns.com/foaf/0.1/>
PREFIX dct:        <http://purl.org/dc/terms/>
PREFIX schema:     <https://schema.org/>
PREFIX xsd:        <http://www.w3.org/2001/XMLSchema#>
PREFIX geo:        <http://www.w3.org/2003/01/geo/wgs84_pos#>

CONSTRUCT
{
    GRAPH ?graph
    {
        ?graph dct:title ?companyName ;
            foaf:primaryTopic ?customer ;
            foaf:topic ?contactPoint, ?employee, ?postalAddress .

        ?customer a schema:Corporation ;
            schema:identifier ?customerID ;
            dct:title ?companyName ;
            schema:legalName ?companyName ;
            schema:contactPoint ?contactPoint ;
            schema:employee ?employee .

        ?contactPoint a schema:ContactPoint ;
            foaf:page ?graph ;
            schema:telephone ?phone ;
            schema:faxNumber ?fax .

        ?employee a schema:Person ;
            foaf:page ?graph ;
            schema:name ?contactName ;
            dct:title ?contactName ;
            schema:jobTitle ?contactTitle ;
            schema:telephone ?phone ;
            schema:faxNumber ?fax ;
            schema:address ?postalAddress ;
            geo:lat ?lat ;
            geo:long ?long .

        ?postalAddress a schema:PostalAddress ;
            foaf:page ?graph ;
            schema:addressCountry ?country ;
            schema:addressLocality ?city ;
            schema:postalCode ?postalCode ;
            schema:streetAddress ?address ;
            schema:addressRegion ?region .
    }
}
WHERE
{
    ?customer_row <#customerID> ?customerID ;
        <#companyName> ?companyName ;
        <#contactName> ?contactName ;
        <#contactTitle> ?contactTitle ;
        <#address> ?address ;
        <#city> ?city ;
        <#postalCode> ?postalCode ;
        <#country> ?country ;
        <#phone> ?phone .

    OPTIONAL {
        ?customer_row <#region> ?region
    }
    OPTIONAL {
        ?customer_row <#fax> ?fax
    }
    OPTIONAL {
        ?customer_row <#lat> ?lat_string 
        BIND(xsd:float(?lat_string) AS ?lat)
    }
    OPTIONAL {
        ?customer_row <#long> ?long_string
        BIND(xsd:float(?long_string) AS ?long)
    }

    BIND(uri(concat(str($base), "customers/")) AS ?container)
    BIND(uri(concat(str(?container), encode_for_uri(?customerID), "/")) AS ?graph)
    BIND(uri(concat(str(?graph), "#this")) AS ?customer)
    BIND(uri(concat(str(?graph), "#contact-point")) AS ?contactPoint)
    BIND(uri(concat(str(?graph), "#employee")) AS ?employee)
    BIND(uri(concat(str(?graph), "#postal-address")) AS ?postalAddress)
}
Title
Customers

Customers

Delimiter
,
EndedAtTime
16 June 2026 21:06
File
customers.csv
Query
Customers
StartedAtTime
16 June 2026 21:04
Title
Customers
Category variable name
country
Chart type
BarChart
Query
Customers by country
Series variable name
customerCount
Title
Customers by country
Text
PREFIX schema: <https://schema.org/>

SELECT ?country (COUNT(DISTINCT ?customer) AS ?customerCount)
WHERE {
    GRAPH ?customerGraph {
        ?customer a schema:Corporation ;
                  schema:employee ?employee .
        ?employee schema:address ?postalAddress .
        ?postalAddress schema:addressCountry ?country .
    }
}
GROUP BY ?country
ORDER BY DESC(?customerCount)
Title
Customers by country

customers.csv

FileName
customers.csv
Format
csv
Sha1sum (hex)
6ac613326ccc56cbdd895cb43bd53b6d953aaa10
Title
customers.csv

customers.rq

FileName
customers.rq
Format
plain
Sha1sum (hex)
187579827e4f917111f5b104eb09347ea530428b
Title
customers.rq
Distinct subjects
91
Number of triples
1080
WasGeneratedBy
Customers

Select customers

Text
PREFIX  schema: <https://schema.org/>

  SELECT DISTINCT  ?customer
  WHERE
    { GRAPH ?doc
        { ?customer  a                schema:Corporation ;
                    schema:legalName  ?companyName
          GRAPH ?orderDoc
            { ?order  schema:customer  ?customer }
        }
    }
  ORDER BY ?companyName
Title
Select customers
Layout mode
Table
Query
Select customers
Category variable name
companyName
Chart type
BarChart
Query
Top customers by revenue
Series variable name
revenue
Title
Top 10 customers by revenue
Text
PREFIX schema: <https://schema.org/>

SELECT ?companyName (SUM(?sale) AS ?revenue)
WHERE {
    GRAPH ?orderGraph {
        ?order schema:customer ?customer ;
               schema:orderedItem ?orderItem .
        ?orderItem schema:orderQuantity ?quantity ;
                   schema:price ?price .
        BIND(?quantity * ?price AS ?sale)
    }
    GRAPH ?customerGraph {
        ?customer schema:legalName ?companyName .
    }
}
GROUP BY ?customer ?companyName
ORDER BY DESC(?revenue)
LIMIT 10
Title
Top customers by revenue