SPARQuickL 3 – Bonne compagnie

Entreprises

# List of business enterprises
SELECT ?business {
  ?business wdt:P31/wdt:P279* wd:Q4830453 . # item is a business enterprise or subclass thereof
}

Essayez

Entreprises avec leur date de création

# List of business enterprises, with their date of creation
SELECT ?business ( SAMPLE( ?date ) AS ?date ) WHERE {
  ?business wdt:P31/wdt:P279* wd:Q4830453 . # item is a business enterprise
  ?business wdt:P571 ?date . # … that was founded at a given point in time
} GROUP BY ?business

Essayez

Entreprises dotées d’un siège, avec leur date de création

# List of business enterprises that have headquarters, with their date of creation
SELECT DISTINCT ?business ?businessLabel ( SAMPLE( ?date ) AS ?date ) WHERE {
  ?business wdt:P31/wdt:P279* wd:Q4830453 . # item is a business enterprise
  ?business wdt:P571 ?date . # … that was founded at a given point in time
  ?business wdt:P159 [] . # and that has headquarters, which we don't keep
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,fr,de,ja,pt,zh" . }
} GROUP BY ?business ?businessLabel

Essayez

Entreprises dotées d’un siège, avec leur date de création et dont le nom commence par « M »

# List of business enterprises that have headquarters, and a name starting with "M", with their date of creation
SELECT ?business ?businessLabel ?layer ?coords ?date WHERE {
  {  
    SELECT DISTINCT ?business ?businessLabel ( SAMPLE( ?century ) AS ?layer ) ?coords ( SAMPLE( ?date ) AS ?date ) WHERE {
      ?business wdt:P31/wdt:P279* wd:Q4830453 . # item is a business enterprise
      ?business wdt:P571 ?date . # … that was founded at a given point in time
      ?business wdt:P159 [] . # … and that has headquarters (which we don't keep)
 
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en,fr,de,ja,pt,zh" . }
    } GROUP BY ?business ?businessLabel ?coords
  }
  FILTER( STRSTARTS( ?businessLabel, "M" ) ) . # … and of which the label starts with "M"
} ORDER BY ?businessLabel ?business # ordered alphabetically if possible, otherwise by the Q<id> of the business enterprise

Essayez

Entreprises dont le nom commence par « M », dotées d’un siège, avec leur date de création et les coordonnées géographiques du siège

# Map of business enterprises' headquarters color-coded with the century the business enterprises were founded
SELECT ?business ?businessLabel ?layer ?coords ?date WHERE {
  {
    SELECT DISTINCT ?business ?businessLabel ( SAMPLE( ?century ) AS ?layer ) ?coords ( SAMPLE( ?date ) AS ?date ) WHERE {
      ?business wdt:P31/wdt:P279* wd:Q4830453 . # item is a business enterprise
      ?business wdt:P571 ?date . # … that was founded at a given point in time
      # … and of which we try to get the geographic coordinates thusly :
      OPTIONAL { ?business p:P159 [ pq:P625 ?coords1 ] . } # first we try to see if the statement about their headquarters has a P625 qualifier
      OPTIONAL { FILTER( !BOUND( ?coords1 ) ) ?business wdt:P159 [ wdt:P625 ?coords2 ] . } # then, if not available, we try to see if the item representing their headquarters has a P625 statement
      OPTIONAL { FILTER( !BOUND( ?coords1 ) && !BOUND( ?coords2 ) ) ?business wdt:P159 [ ?property [ wdt:P625 ?coords3 ] ] . VALUES ?property { wdt:P131 wdt:P276 } . } # lastly, if still not available, we try to see if the item representing their headquarters is located (administratively or not) in a given entity which has coordinates
      BIND( COALESCE( ?coords1, ?coords2, ?coords3 ) AS ?coords ) . # finally we try to bind the first of the three that is set, if any
      FILTER( BOUND( ?coords ) ) . # we remove all companies for which it was impossible to find coordinates for the headquarters
      BIND( FLOOR( ( YEAR( ?date ) - 1 ) / 100 ) + 1 AS ?century ) . # get the century from the date, which will be displayed as a colored layer on the map
 
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en,fr,de,ja,pt,zh" . }
    } GROUP BY ?business ?businessLabel ?coords
  }
  FILTER( STRSTARTS( ?businessLabel, "M" ) ) . # … and of which the label starts with "M"
} ORDER BY ?businessLabel ?business # ordered alphabetically if possible, otherwise by the Q<id> of the business enterprise

Essayez

Résultat final

Lien direct vers la carte des sièges sociaux des entreprises dont le nom commence par « M », avec le siècle de fondation codé par couleur

Petit jeu bonus : essayez de trouver (sans tricher) les sièges sociaux de Mercedes-Benz, des dix compagnies dont le nom commence par « Millennium », et de Microsoft 🙂

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">