PREFIX gesli: <https://gesli.example/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?customerName ?counterpartyType ?counterpartyName ?country ?region
WHERE {
  ?customer rdfs:label ?customerName .

  {
    ?customer gesli:hasCustomerCounterparty ?counterparty .
    BIND("客户的客户" AS ?counterpartyType)
  }
  UNION
  {
    ?customer gesli:hasSupplierCounterparty ?counterparty .
    BIND("客户的供应商" AS ?counterpartyType)
  }

  ?counterparty rdfs:label ?counterpartyName .
  OPTIONAL { ?counterparty gesli:country ?country . }
  OPTIONAL { ?counterparty gesli:region ?region . }
}
ORDER BY ?customerName ?counterpartyType
