query-caddb9c1f295e3837d170c1e3b42c6c2

rq turtle/ttl

German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM) German states, ordered by the number of company headquarters per million inhabitants

Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)

Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)

Limits: states without population missing; company data in Wikidata is always incomplete

Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.

SELECT ?state ?stateLabel ?companies ?population (?companies/?population1000000 AS ?companiesPerM) WHERE { { SELECT ?state (count() as ?companies) WHERE { {SELECT DISTINCT ?company ?state WHERE { ?state wdt:P31 wd:Q1221156 . ?company wdt:P31/wdt:P279 wd:Q4830453 . ?company wdt:P159/wdt:P131 ?state . FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies } } } GROUP BY ?state } ?state wdt:P1082 ?population SERVICE wikibase:label { bd:serviceParam wikibase:language "de" } } ORDER BY DESC(?companiesPerM)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# German states, ordered by the number of company headquarters per million inhabitants
# Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)
# Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)
# Limits: states without population missing; company data in Wikidata is always incomplete
# Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.
SELECT
  ?state ?stateLabel
  ?companies
  ?population
  (?companies/?population*1000000 AS ?companiesPerM)
WHERE
{
  { SELECT ?state (count(*) as ?companies) WHERE {
    {SELECT DISTINCT ?company ?state WHERE {
      ?state wdt:P31 wd:Q1221156 .
      ?company wdt:P31/wdt:P279* wd:Q4830453 .
      ?company wdt:P159/wdt:P131* ?state .
      FILTER NOT EXISTS{ ?company wdt:P576 ?date } # don't count dissolved companies
    } }
  } GROUP BY ?state }
    ?state wdt:P1082 ?population
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de" }
}
ORDER BY DESC(?companiesPerM)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?companies"):::projected v7("?companiesPerM") v2("?company") v3("?date") v6("?population"):::projected v4("?state"):::projected a1((" ")) a2((" ")) c12(["de"]):::literal c10(["bd:serviceParam"]):::iri c3(["wd:Q1221156"]):::iri c5(["wd:Q4830453"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"wdt:P576"--> e0v2 e0v1("?company"):::projected e0v2("?date"):::projected end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c1 f0 --> v3 v2 --"wdt:P576"--> v3 v4 --"wdt:P31"--> c3 v2 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c5 v2 --"wdt:P159"--> a2 a2 --"wdt:P131"--> v4 bind2[/"count(*)"/] bind2 --as--o v5 v4 --"wdt:P1082"--> v6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end bind3[/"?companies / ?population * '1000000^^xsd:integer'"/] v5 --o bind3 v6 --o bind3 bind3 --as--o v7