PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
SELECT ?company ?companyLabel ?hq ?hqLabel ?revAmount ?revUnitLabel ?date ?netAmount ?profitMargin WHERE {
  ?company wdt:P31 / wdt:P279 * wd:Q783794 .
  FILTER ( ?company NOT IN ( wd:Q100707321 , wd:Q12021780 ) ) OPTIONAL {
    ?company wdt:P159 ?hq .
    ?hq rdfs:label ?hqLabel
    FILTER ( LANG( ?hqLabel ) = "en" )
  }
  OPTIONAL {
    ?company rdfs:label ?companyLabel FILTER ( LANG( ?companyLabel ) = "en" )
  }
  FILTER ( EXISTS {
    ?company wdt:P17 wd:Q213
  }
  || EXISTS {
    ?company wdt:P159 ?hq2 .
    ?hq2 wdt:P17 wd:Q213
  }
  || EXISTS {
    ?company wdt:P159 ?hq3 .
    ?hq3 wdt:P131 * ?admin .
    ?admin wdt:P17 wd:Q213
  }
  ) ?company p:P2139 ?revStmt .
  ?revStmt psv:P2139 ?revValNode .
  ?revValNode wikibase:quantityAmount ?revAmount .
  OPTIONAL {
    ?revValNode wikibase:quantityUnit ?revUnit .
    ?revUnit rdfs:label ?revUnitLabel
    FILTER ( LANG( ?revUnitLabel ) = "en" )
  }
  ?revStmt pq:P585 ?date .
  ?company p:P2295 ?netStmt .
  ?netStmt psv:P2295 ?netValNode .
  ?netValNode wikibase:quantityAmount ?netAmount .
  ?netStmt pq:P585 ?date .
  FILTER ( ?revAmount != 0 ) BIND( ( ?netAmount / ?revAmount ) * 100 AS ?profitMarginRaw ) BIND( ( ROUND( ?profitMarginRaw * 100 ) / 100 ) AS ?profitMargin )
}
ORDER BY ?profitMargin
LIMIT 20

Using entities:
- Adental Czech Republic (wd:Q100707321): is instance of business / Czech medical company
- Investiční a poštovní banka (wd:Q12021780), also known as Investiční banka, IPB: is instance of Bank / is instance of business / is instance of bank / is instance of former entity / is instance of enterprise / former Czech bank / governmental organization
- Czech Republic (wd:Q213), also known as CZ, CZE, Czechia, CZR: is instance of Republic / is instance of country / is instance of republic / is instance of sovereign state / is instance of successor state / is instance of landlocked country / country in Central Europe / country in Europe / republic in Central Europe
- company (wd:Q783794), also known as co., firm: is instance of type of organization / is instance of type of organisation / is instance of legal form / is subclass of legal person / is subclass of organisation / is subclass of organization / an organisation of people with a common purpose, such as a business / legal entity representing an association of people, whether natural, legal or a mixture of both, with a specific objective

Using properties:
- located in the administrative territorial entity (wd:P131 as wdt), also known as administrative territorial entity, administrative territory, city, happens in, in, etc.: is subproperty of location / is subproperty of part of / the item is located on the territory of the following administrative entity / the item is located on the territory of the following administrative entity / the item is located on the territory of the following ... the item falls only partially into the administrative entity. / the item is located on the territory of the following ... the item falls only partially into the administrative entity.
- headquarters location (wd:P159 as wdt), also known as admin HQ, based in, garrison, head office location, head quarters, etc.: is subproperty of significant place / city or town where an organization's headquarters is or has been situated. Use P276 qualifier for specific building / specific location where an organisation's HQ is or has been located / specific location where an organisation's HQ is or has been located
- country (wd:P17 as wdt), also known as host country, land, sovereign state, state, P17: is subproperty of located in the administrative territorial entity / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings)
- total revenue (wd:P2139 as p/psv), also known as gross revenue, income, net sales, revenue, sales, etc.: income gained by an organization during a given time frame. Not to be confused with fiscal revenue
- net profit (wd:P2295 as p/psv), also known as bottom line, clear gain, clear profit, net earnings, net income, etc.: private entity profit after accounting for all costs
- subclass of (wd:P279 as wdt), also known as all members of this class also belong to, category of, form of, has superclass, is a class of, etc.: this item is a subclass (subset) of that item; ALL instances ... of volcanic landform); Everest is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain
- instance of (wd:P31 as wdt), also known as example of, has type, is a, is an, is of type, etc.: that class of which this subject is a particular example and ... a subclass of mountain (and an instance of volcanic landform) / type to which this subject corresponds/belongs. Different ... and the volcano is a type (instance) of volcanic landform
- point in time (wd:P585 as pq), also known as as of, at time, by date, date, during, etc.: date something took place, existed or a statement was true; for providing time use the "refine date" property (P4241) / time and date something took place, existed or a statement was true / time and date something took place, existed or a statement was true / time and date something took place, existed or a statement was true

Got 20 rows and 9 columns, showing the first 5 and last 5 rows below:
| company                              | companyLabel                    | hq                | hqLabel          | revAmount             | revUnitLabel           | date                                | netAmount                 | profitMargin           |
| ------------------------------------ | ------------------------------- | ----------------- | ---------------- | --------------------- | ---------------------- | ----------------------------------- | ------------------------- | ---------------------- |
| CITIC Europe Holdings (wd:Q47466468) | CITIC Europe Holdings (lang:en) | Prague (wd:Q1085) | Prague (lang:en) | 1092000 (xsd:decimal) | Czech koruna (lang:en) | 2018-01-01T00:00:00Z (xsd:dateTime) | -5403679000 (xsd:decimal) | -494842 (xsd:decimal)  |
| CITIC Europe Holdings (wd:Q47466468) | CITIC Europe Holdings (lang:en) | Prague (wd:Q1085) | Prague (lang:en) | 1092000 (xsd:decimal) | Czech koruna (lang:en) | 2018-01-01T00:00:00Z (xsd:dateTime) | -5403679000 (xsd:decimal) | -494842 (xsd:decimal)  |
| CITIC Europe Holdings (wd:Q47466468) | CITIC Europe Holdings (lang:en) | Prague (wd:Q1085) | Prague (lang:en) | 1092000 (xsd:decimal) | Czech koruna (lang:en) | 2018-01-01T00:00:00Z (xsd:dateTime) | -4725729000 (xsd:decimal) | -432759 (xsd:decimal)  |
| CITIC Europe Holdings (wd:Q47466468) | CITIC Europe Holdings (lang:en) | Prague (wd:Q1085) | Prague (lang:en) | 1092000 (xsd:decimal) | Czech koruna (lang:en) | 2018-01-01T00:00:00Z (xsd:dateTime) | -4725729000 (xsd:decimal) | -432759 (xsd:decimal)  |
| CITIC Europe Holdings (wd:Q47466468) | CITIC Europe Holdings (lang:en) | Prague (wd:Q1085) | Prague (lang:en) | 49000 (xsd:decimal)   | Czech koruna (lang:en) | 2015-01-01T00:00:00Z (xsd:dateTime) | -119986000 (xsd:decimal)  | -244869 (xsd:decimal)  |
| ...                                  | ...                             | ...               | ...              | ...                   | ...                    | ...                                 | ...                       | ...                    |
| Magna Energy Storage (wd:Q58875490)  | Magna Energy Storage (lang:en)  | Prague (wd:Q1085) | Prague (lang:en) | 761000 (xsd:decimal)  | Czech koruna (lang:en) | 2020-01-01T00:00:00Z (xsd:dateTime) | -57802000 (xsd:decimal)   | -7595.53 (xsd:decimal) |
| Magna Energy Storage (wd:Q58875490)  | Magna Energy Storage (lang:en)  | Prague (wd:Q1085) | Prague (lang:en) | 761000 (xsd:decimal)  | Czech koruna (lang:en) | 2020-01-01T00:00:00Z (xsd:dateTime) | -57802000 (xsd:decimal)   | -7595.53 (xsd:decimal) |
| Xixoio (wd:Q110000079)               | Xixoio (lang:en)                | Prague (wd:Q1085) | Prague (lang:en) | 260000 (xsd:decimal)  | Czech koruna (lang:en) | 2019-01-01T00:00:00Z (xsd:dateTime) | -11220000 (xsd:decimal)   | -4315.38 (xsd:decimal) |
| Xixoio (wd:Q110000079)               | Xixoio (lang:en)                | Prague (wd:Q1085) | Prague (lang:en) | 260000 (xsd:decimal)  | Czech koruna (lang:en) | 2019-01-01T00:00:00Z (xsd:dateTime) | -11220000 (xsd:decimal)   | -4315.38 (xsd:decimal) |
| Warhorse Studios (wd:Q7969414)       | Warhorse Studios (lang:en)      | Prague (wd:Q1085) | Prague (lang:en) | 1130000 (xsd:decimal) | Czech koruna (lang:en) | 2016-01-01T00:00:00Z (xsd:dateTime) | -26483000 (xsd:decimal)   | -2343.63 (xsd:decimal) |

Answer:
I ran a query that returns up to 20 companies (instances/subclasses of "company") associated with the Czech Republic (via P17 or via headquarters P159 / admin chain) excluding Adental Czech Republic (wd:Q100707321) and Investiční a poštovní banka (wd:Q12021780). For each company it returns:
- company (IRI) and optional English label,
- headquarters (IRI) and optional English label,
- a revenue amount (psv:P2139 wikibase:quantityAmount), the revenue unit label when available (from the quantity unit), and the point-in-time date (pq:P585) for that revenue statement,
- a net profit amount (psv:P2295 wikibase:quantityAmount) for a net profit statement with the same point-in-time date,
- the profit margin computed as (net / revenue) * 100 and rounded to two decimal places.

Important notes about the returned data (observations from the query results):
- The query pairs revenue and net-profit statements that share the same pq:P585 qualifier (the same point-in-time). Only pairs with matching dates are included.
- Units are shown when the revenue quantity node has a wikibase:quantityUnit; many monetary values use the Czech koruna unit when present.
- Some rows may show very large or very negative profit margins because the raw amounts in Wikidata may be recorded at different scales or reflect losses; the query uses the literal numeric amounts as stored.
- The query returns the actual Wikidata IRIs (identifiers) for companies and headquarters as requested.

If you want:
- I can refine the pairing logic to choose the most recent revenue and net-profit values per company (even when dates do not match),
- or normalize currencies/units where possible (e.g., convert to a common currency) — note that currency conversion would require external exchange rate data.

Below is the SPARQL I executed (same as above).

I ran a query that returns up to 20 companies (instances/subclasses of "company") associated with the Czech Republic (via P17 or via headquarters P159 / admin chain) excluding Adental Czech Republic (wd:Q100707321) and Investiční a poštovní banka (wd:Q12021780). For each company it returns:
- company (IRI) and optional English label,
- headquarters (IRI) and optional English label,
- a revenue amount (psv:P2139 wikibase:quantityAmount), the revenue unit label when available (from the quantity unit), and the point-in-time date (pq:P585) for that revenue statement,
- a net profit amount (psv:P2295 wikibase:quantityAmount) for a net profit statement with the same point-in-time date,
- the profit margin computed as (net / revenue) * 100 and rounded to two decimal places.

Important notes about the returned data (observations from the query results):
- The query pairs revenue and net-profit statements that share the same pq:P585 qualifier (the same point-in-time). Only pairs with matching dates are included.
- Units are shown when the revenue quantity node has a wikibase:quantityUnit; many monetary values use the Czech koruna unit when present.
- Some rows may show very large or very negative profit margins because the raw amounts in Wikidata may be recorded at different scales or reflect losses; the query uses the literal numeric amounts as stored.
- The query returns the actual Wikidata IRIs (identifiers) for companies and headquarters as requested.

If you want:
- I can refine the pairing logic to choose the most recent revenue and net-profit values per company (even when dates do not match),
- or normalize currencies/units where possible (e.g., convert to a common currency) — note that currency conversion would require external exchange rate data.

Below is the SPARQL I executed (same as above).

SPARQL query over wikidata:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
SELECT ?company ?companyLabel ?hq ?hqLabel ?revAmount ?revUnitLabel ?date ?netAmount ?profitMargin WHERE {
  ?company wdt:P31 / wdt:P279 * wd:Q783794 .
  FILTER ( ?company NOT IN ( wd:Q100707321 , wd:Q12021780 ) ) OPTIONAL {
    ?company wdt:P159 ?hq .
    ?hq rdfs:label ?hqLabel
    FILTER ( LANG( ?hqLabel ) = "en" )
  }
  OPTIONAL {
    ?company rdfs:label ?companyLabel FILTER ( LANG( ?companyLabel ) = "en" )
  }
  FILTER ( EXISTS {
    ?company wdt:P17 wd:Q213
  }
  || EXISTS {
    ?company wdt:P159 ?hq2 .
    ?hq2 wdt:P17 wd:Q213
  }
  || EXISTS {
    ?company wdt:P159 ?hq3 .
    ?hq3 wdt:P131 * ?admin .
    ?admin wdt:P17 wd:Q213
  }
  ) ?company p:P2139 ?revStmt .
  ?revStmt psv:P2139 ?revValNode .
  ?revValNode wikibase:quantityAmount ?revAmount .
  OPTIONAL {
    ?revValNode wikibase:quantityUnit ?revUnit .
    ?revUnit rdfs:label ?revUnitLabel
    FILTER ( LANG( ?revUnitLabel ) = "en" )
  }
  ?revStmt pq:P585 ?date .
  ?company p:P2295 ?netStmt .
  ?netStmt psv:P2295 ?netValNode .
  ?netValNode wikibase:quantityAmount ?netAmount .
  ?netStmt pq:P585 ?date .
  FILTER ( ?revAmount != 0 ) BIND( ( ?netAmount / ?revAmount ) * 100 AS ?profitMarginRaw ) BIND( ( ROUND( ?profitMarginRaw * 100 ) / 100 ) AS ?profitMargin )
}
ORDER BY ?profitMargin
LIMIT 20

Using entities:
- Adental Czech Republic (wd:Q100707321): is instance of business / Czech medical company
- Investiční a poštovní banka (wd:Q12021780), also known as Investiční banka, IPB: is instance of Bank / is instance of business / is instance of bank / is instance of former entity / is instance of enterprise / former Czech bank / governmental organization
- Czech Republic (wd:Q213), also known as CZ, CZE, Czechia, CZR: is instance of Republic / is instance of country / is instance of republic / is instance of sovereign state / is instance of successor state / is instance of landlocked country / country in Central Europe / country in Europe / republic in Central Europe
- company (wd:Q783794), also known as co., firm: is instance of type of organization / is instance of type of organisation / is instance of legal form / is subclass of legal person / is subclass of organisation / is subclass of organization / an organisation of people with a common purpose, such as a business / legal entity representing an association of people, whether natural, legal or a mixture of both, with a specific objective

Using properties:
- located in the administrative territorial entity (wd:P131 as wdt), also known as administrative territorial entity, administrative territory, city, happens in, in, etc.: is subproperty of location / is subproperty of part of / the item is located on the territory of the following administrative entity / the item is located on the territory of the following administrative entity / the item is located on the territory of the following ... the item falls only partially into the administrative entity. / the item is located on the territory of the following ... the item falls only partially into the administrative entity.
- headquarters location (wd:P159 as wdt), also known as admin HQ, based in, garrison, head office location, head quarters, etc.: is subproperty of significant place / city or town where an organization's headquarters is or has been situated. Use P276 qualifier for specific building / specific location where an organisation's HQ is or has been located / specific location where an organisation's HQ is or has been located
- country (wd:P17 as wdt), also known as host country, land, sovereign state, state, P17: is subproperty of located in the administrative territorial entity / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings)
- total revenue (wd:P2139 as p/psv), also known as gross revenue, income, net sales, revenue, sales, etc.: income gained by an organization during a given time frame. Not to be confused with fiscal revenue
- net profit (wd:P2295 as p/psv), also known as bottom line, clear gain, clear profit, net earnings, net income, etc.: private entity profit after accounting for all costs
- subclass of (wd:P279 as wdt), also known as all members of this class also belong to, category of, form of, has superclass, is a class of, etc.: this item is a subclass (subset) of that item; ALL instances ... of volcanic landform); Everest is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain / this item is a subclass (subset) of that item; all instances ... instance of volcanic landform); K2 is an instance of mountain
- instance of (wd:P31 as wdt), also known as example of, has type, is a, is an, is of type, etc.: that class of which this subject is a particular example and ... a subclass of mountain (and an instance of volcanic landform) / type to which this subject corresponds/belongs. Different ... and the volcano is a type (instance) of volcanic landform
- point in time (wd:P585 as pq), also known as as of, at time, by date, date, during, etc.: date something took place, existed or a statement was true; for providing time use the "refine date" property (P4241) / time and date something took place, existed or a statement was true / time and date something took place, existed or a statement was true / time and date something took place, existed or a statement was true

Execution result:
Got 20 rows and 9 columns, showing the first 5 and last 5 rows below:
| company                              | companyLabel                    | hq                | hqLabel          | revAmount             | revUnitLabel           | date                                | netAmount                 | profitMargin           |
| ------------------------------------ | ------------------------------- | ----------------- | ---------------- | --------------------- | ---------------------- | ----------------------------------- | ------------------------- | ---------------------- |
| CITIC Europe Holdings (wd:Q47466468) | CITIC Europe Holdings (lang:en) | Prague (wd:Q1085) | Prague (lang:en) | 1092000 (xsd:decimal) | Czech koruna (lang:en) | 2018-01-01T00:00:00Z (xsd:dateTime) | -5403679000 (xsd:decimal) | -494842 (xsd:decimal)  |
| CITIC Europe Holdings (wd:Q47466468) | CITIC Europe Holdings (lang:en) | Prague (wd:Q1085) | Prague (lang:en) | 1092000 (xsd:decimal) | Czech koruna (lang:en) | 2018-01-01T00:00:00Z (xsd:dateTime) | -5403679000 (xsd:decimal) | -494842 (xsd:decimal)  |
| CITIC Europe Holdings (wd:Q47466468) | CITIC Europe Holdings (lang:en) | Prague (wd:Q1085) | Prague (lang:en) | 1092000 (xsd:decimal) | Czech koruna (lang:en) | 2018-01-01T00:00:00Z (xsd:dateTime) | -4725729000 (xsd:decimal) | -432759 (xsd:decimal)  |
| CITIC Europe Holdings (wd:Q47466468) | CITIC Europe Holdings (lang:en) | Prague (wd:Q1085) | Prague (lang:en) | 1092000 (xsd:decimal) | Czech koruna (lang:en) | 2018-01-01T00:00:00Z (xsd:dateTime) | -4725729000 (xsd:decimal) | -432759 (xsd:decimal)  |
| CITIC Europe Holdings (wd:Q47466468) | CITIC Europe Holdings (lang:en) | Prague (wd:Q1085) | Prague (lang:en) | 49000 (xsd:decimal)   | Czech koruna (lang:en) | 2015-01-01T00:00:00Z (xsd:dateTime) | -119986000 (xsd:decimal)  | -244869 (xsd:decimal)  |
| ...                                  | ...                             | ...               | ...              | ...                   | ...                    | ...                                 | ...                       | ...                    |
| Magna Energy Storage (wd:Q58875490)  | Magna Energy Storage (lang:en)  | Prague (wd:Q1085) | Prague (lang:en) | 761000 (xsd:decimal)  | Czech koruna (lang:en) | 2020-01-01T00:00:00Z (xsd:dateTime) | -57802000 (xsd:decimal)   | -7595.53 (xsd:decimal) |
| Magna Energy Storage (wd:Q58875490)  | Magna Energy Storage (lang:en)  | Prague (wd:Q1085) | Prague (lang:en) | 761000 (xsd:decimal)  | Czech koruna (lang:en) | 2020-01-01T00:00:00Z (xsd:dateTime) | -57802000 (xsd:decimal)   | -7595.53 (xsd:decimal) |
| Xixoio (wd:Q110000079)               | Xixoio (lang:en)                | Prague (wd:Q1085) | Prague (lang:en) | 260000 (xsd:decimal)  | Czech koruna (lang:en) | 2019-01-01T00:00:00Z (xsd:dateTime) | -11220000 (xsd:decimal)   | -4315.38 (xsd:decimal) |
| Xixoio (wd:Q110000079)               | Xixoio (lang:en)                | Prague (wd:Q1085) | Prague (lang:en) | 260000 (xsd:decimal)  | Czech koruna (lang:en) | 2019-01-01T00:00:00Z (xsd:dateTime) | -11220000 (xsd:decimal)   | -4315.38 (xsd:decimal) |
| Warhorse Studios (wd:Q7969414)       | Warhorse Studios (lang:en)      | Prague (wd:Q1085) | Prague (lang:en) | 1130000 (xsd:decimal) | Czech koruna (lang:en) | 2016-01-01T00:00:00Z (xsd:dateTime) | -26483000 (xsd:decimal)   | -2343.63 (xsd:decimal) |

[System]
You are a question answering assistant. Your job is to generate a SPARQL query to answer a given user question.

You should follow a step-by-step approach to generate the SPARQL query:
1. Determine possible entities and properties implied by the user question.
2. Search for the entities and properties in the knowledge graphs. Where applicable, constrain the searches with already identified entities and properties.
3. Gradually build up the SPARQL query using the identified entities and properties. Start with simple queries and add more complexity as needed. Execute intermediate queries to get feedback and to verify your assumptions. You may need to refine or rethink your current plan based on the query results and go back to step 2 if needed, possibly multiple times.
4. Use the answer or cancel function to finalize your answer and stop the generation process.

Available knowledge graphs:
- wikidata at http://localhost:7001 with prefix index for entities and similarity index for properties, and notes:
  - P106 = occupation. Use wdt:P106 to get occupations and fetch English labels with rdfs:label + FILTER(LANG(?label)="en"). When returning human occupations confirm the subject is human (wdt:P31 wd:Q5) to avoid non-human items.
  - Population (P1082) and tabular (P4179): use wdt:P1082 for quick/direct values; for time-series/point-in-time use p:P1082 + ps:P1082 + pq:P585 and ORDER BY pq:P585 DESC. Inspect statement qualifiers (e.g., 'applies to part') and prov:wasDerivedFrom references (pr:P854 etc.) to detect city-proper vs metro/prefecture scopes before using values.
  - Common person properties: P31 (instance of human Q5), P106 (occupation), P569 (date of birth), P19 (place of birth), P27 (country of citizenship), P21 (sex/gender), P166 (award received). Use wdt: for direct values when possible.
  - P17 (country) can be incomplete/misleading for places (historical/overseas tags). To get modern cities in a country combine: instance-of city (P31=Q515) + wdt:P17 OR use wdt:P131* to find an admin parent whose wdt:P17 = the country. Also cross-check coordinates (P625) or admin hierarchy to spot outliers.
  - When filtering by date of birth (P569) use xsd:dateTime comparisons (e.g. >= "1900-01-01T00:00:00Z"^^xsd:dateTime). Be aware many items have year-only or imprecise dates and coverage is biased toward notable/public figures (sportspeople, politicians, artists).
  - To retrieve qualifiers (e.g., award year) use the statement/qualifier pattern: p:Pxxx / ps:Pxxx / pq:P585. Use wdt:Pxxx for normalized/direct values when you don't need qualifiers. Example: p:P166 + pq:P585 gives award year.
  - To get a person's occupations: use wdt:P106 for direct/normalized values and rdfs:label for human-readable names (FILTER(LANG(...))). Example: wd:Q... wdt:P106 ?occ . ?occ rdfs:label ?occLabel . FILTER(LANG(?occLabel)="en").
  - P166 = award received. Use wdt:P166 for normalized/direct values when you only need award items. To get award years or qualifiers use p:P166 / ps:P166 / pq:P585. Many statements lack pq:P585 — use OPTIONAL { ?stmt pq:P585 ?date } and ORDER BY DESC(?date). When listing award winners, filter ?person wdt:P31 wd:Q5 to ensure humans.
  - Population time-series pattern: wd:Q... p:P1082 ?stmt . ?stmt ps:P1082 ?pop . OPTIONAL { ?stmt pq:P585 ?date } . ORDER BY DESC(?date). pq:P585 is the point-in-time qualifier. IMPORTANT: time-series may mix scopes (city proper vs metro) — e.g., Tokyo has a 2016 entry ~38,140,000 likely metro vs smaller city figures. Inspect qualifiers/references for scope before use.
  - Use wdt:P131* to traverse the admin hierarchy and compare wdt:P17 on the place vs an admin parent to detect historical/colonial country assignments. When mismatches appear, inspect the admin parent's instance-of (P31), labels, qualifiers and references to interpret the historical scope.
  - wdt:P106 often yields multiple occupations for a person. Use GROUP_CONCAT(DISTINCT ?occLabel; separator=", ") or return multiple rows. Always fetch labels with rdfs:label + FILTER(LANG(?label)="en") to get readable occupation names.
  - When a search_entity returns multiple hits (person vs sculpture vs memorial), confirm you selected the human/statements by checking wdt:P31 (instance of) and relevant wdt: properties (e.g., wdt:P106). This avoids using a non-human QID by mistake.
  - search_autocomplete can be constrained with a SPARQL pattern containing ?search (e.g., SELECT * WHERE { ?search wdt:P31 wd:Q5 }). Use constraints to focus results (e.g., humans) and avoid ambiguous fallbacks; if it returns no results, fallback to search_entity and verify wdt:P31.
  - Use search_property_of_entity to find relevant properties for an entity (e.g., 'award' -> P166) and search_object_of_property to discover candidate objects (e.g., 'physicist' for P106). This reduces guessing P/Q ids and surfaces qualifiers.
  - Inspect statement references and qualifiers: use prov:wasDerivedFrom on p: statements to find sources, and check qualifiers (e.g., 'applies to part' or other scope qualifiers) to disambiguate city vs metro vs admin area. Reference labels can be empty; inspect reference node properties for URLs or publication dates.

Index types used for entities and properties:
- Prefix index: Retrieves items by overlap between query keywords and item words. The query keywords can match item words exactly or as prefixes.
- Similarity index: Retrieves items by cosine similarity between their embeddings and the query embedding.

General notes across knowledge graphs:
- Use rdfs:label + FILTER(LANG(?label)="en") for labels; avoid SERVICE wikibase:label. Use wdt:Pxxx for normalized/direct values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access statement qualifiers (e.g., award year via pq:P585). When dates matter, prefer xsd:dateTime and watch for year-only precision.
- Practical query patterns: use rdfs:label + FILTER(LANG(...)) for labels. Use wdt:Pxxx for direct/normalized values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access qualifiers (dates via pq:P585). For dates use xsd:dateTime and expect year-only precision. For places: combine P17 with P131 or coordinate (P625) filters to avoid historical/overseas mismatches.
- Use OPTIONAL for pq: qualifiers (e.g., pq:P585), sort by qualifier (ORDER BY pq:P585 DESC) to prefer recent values. Use GROUP_CONCAT to combine multiple labels/values in one row. Watch for typed literals (xsd:dateTime, xsd:decimal) when filtering or sorting.
- Before querying, use search_entity to resolve human-friendly names to wd:Q identifiers and verify instance-of (e.g., check wdt:P31 = wd:Q5 for humans) to avoid ambiguous matches. Prefer the top match but programmatically confirm P31 before using its data.
- Use search_property to confirm property identifiers (e.g., "country" -> P17) before embedding them in queries. This prevents mistakes from assuming an ID and helps pick the best property if multiple choices exist.
- search_autocomplete can fall back to an unconstrained search or error when there are too many candidates. If this happens (e.g., "more than the maximum supported number of subject candidates"), retry with narrower constraints such as instance-of (wdt:P31), additional type filters, or short prefixes to reduce the candidate set; otherwise fallback to search_entity and verify wdt:P31.
- Use list(...) to inspect all triples on an entity for exploration, but expect large results for notable items. Prefer wdt: properties or targeted p:/ps:/pq: patterns in SPARQL when you need normalized values or qualifiers, respectively.
- Before embedding property or item IDs in SPARQL, use search_property, search_property_of_entity, and search_object_of_property to discover the appropriate P/PID or object QIDs. This reduces errors from guessing IDs and surfaces better property alternatives and qualifiers.
- search_constrained and search_autocomplete can return no results for constrained queries or when the index is large. If they fail, fallback to search_entity + verify P31 (or use search_property_of_entity). Constrain with instance-of (wdt:P31) or other properties in the SPARQL to improve matches.
- When selecting awards by year, prefer xsd:dateTime range filters (e.g., >= "2001-01-01T00:00:00Z"^^xsd:dateTime && < "2002-01-01T00:00:00Z"^^xsd:dateTime) instead of YEAR() for portability and precision.
- When selecting award winners via wdt:P166, filter ?person wdt:P31 wd:Q5 to ensure humans — fictional characters or non-humans may have award claims. If you need award years use p:P166 / ps:P166 / pq:P585 and OPTIONAL { ?stmt pq:P585 ?year } to retrieve qualifier years.
- Use wdt:P625 (coordinates) together with wdt:P131* and wdt:P17 checks to validate a place's modern country or to filter by geography. When country labels mismatch historically, inspect admin parents and coordinates to resolve whether the item refers to historical/colonial scope or current boundaries.
- Prefer wdt:Pxxx for normalized/direct values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access qualifiers (e.g., pq:P585 for award year). Always fetch labels with rdfs:label + FILTER(LANG(?label) = "en").
- If search_autocomplete returns too many candidates or errors, retry with constraints (e.g., SELECT * WHERE { ?search wdt:P31 wd:Q5 }) or narrower query text. If still failing, fallback to search_entity and verify wdt:P31 for type checks.
- For award-year queries use p:P166 / ps:P166 / pq:P585 to access award statements and year qualifiers. Filter by xsd:dateTime ranges (e.g., >= "2020-01-01T00:00:00Z"^^xsd:dateTime && < "2021-01-01T00:00:00Z"^^xsd:dateTime) instead of YEAR() for robustness.
- Use search_property_of_entity to surface relevant properties for an entity (e.g., 'birth' -> P569/P19). list(...) can inspect triples but may return large results for notable items—prefer targeted wdt: patterns (wdt:Pxxx) or p:/ps:/pq: patterns when you need qualifiers.

SPARQL prefixes for use in function calls:
- bd: <http://www.bigdata.com/rdf#
- cc: <http://creativecommons.org/ns#
- data: <https://www.wikidata.org/wiki/Special:EntityData/
- dc: <http://purl.org/dc/elements/1.1/
- dct: <http://purl.org/dc/terms/
- foaf: <http://xmlns.com/foaf/0.1/
- geo: <http://www.opengis.net/ont/geosparql#
- geof: <http://www.opengis.net/def/function/geosparql/
- gn: <http://www.geonames.org/ontology#
- hint: <http://www.bigdata.com/queryHints#
- imdb: <https://www.imdb.com/
- math: <http://www.w3.org/2005/xpath-functions/math#
- ontolex: <http://www.w3.org/ns/lemon/ontolex#
- owl: <http://www.w3.org/2002/07/owl#
- p: <http://www.wikidata.org/prop/
- pq: <http://www.wikidata.org/prop/qualifier/
- pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/
- pqv: <http://www.wikidata.org/prop/qualifier/value/
- pr: <http://www.wikidata.org/prop/reference/
- prn: <http://www.wikidata.org/prop/reference/value-normalized/
- prov: <http://www.w3.org/ns/prov#
- prv: <http://www.wikidata.org/prop/reference/value/
- ps: <http://www.wikidata.org/prop/statement/
- psn: <http://www.wikidata.org/prop/statement/value-normalized/
- psv: <http://www.wikidata.org/prop/statement/value/
- qb: <http://purl.org/linked-data/cube#
- qfn: <http://qlever.cs.uni-freiburg.de/function#
- ql: <http://qlever.cs.uni-freiburg.de/builtin-functions/
- qlss: <https://qlever.cs.uni-freiburg.de/spatialSearch/
- rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
- rdfs: <http://www.w3.org/2000/01/rdf-schema#
- ref: <http://www.wikidata.org/reference/
- s: <http://www.wikidata.org/entity/statement/
- schema: <http://schema.org/
- skos: <http://www.w3.org/2004/02/skos/core#
- v: <http://www.wikidata.org/value/
- void: <http://rdfs.org/ns/void#
- wd: <http://www.wikidata.org/entity/
- wdno: <http://www.wikidata.org/prop/novalue/
- wdt: <http://www.wikidata.org/prop/direct/
- wdtn: <http://www.wikidata.org/prop/direct-normalized/
- wikibase: <http://wikiba.se/ontology#
- xsd: <http://www.w3.org/2001/XMLSchema#

Additional rules to follow:
- Explain your thought process before and after each step and function call.
- Do not just use or make up entity or property identifiers without verifying their existence in the knowledge graphs first.
- Do not ask the user for clarifications without first attempting to complete the task. If the task input is incomplete or ambiguous, try to make reasonable assumptions and document them.
- Do not use "SERVICE wikibase:label { bd:serviceParam wikibase:language ..." in SPARQL queries. It is not SPARQL standard and unsupported by the used QLever SPARQL endpoints. Use rdfs:label or similar properties to get labels instead.
- Always execute your final SPARQL query before giving an answer to make sure it returns the expected results.
- The SPARQL query should always return the actual identifiers / IRIs of the items in its result. It additionally may return labels or other human-readable information, but they are optional and should be put within optional clauses unless explicitly requested by the user.
- Do not stop early if there are still obvious improvements to be made to the SPARQL query. For example, keep refining your SPARQL query if its result contains irrelevant items or is missing items you expected.
- Do not perform additional computation (e.g. filtering, sorting, calculations) on the result of the SPARQL query to determine the answer. All computation should be done solely within SPARQL.
- For questions with a "True" or "False" answer the SPARQL query should be an ASK query.

[User] What are the businesses headquartered in the Czech Republic, excluding Adental Czech Republic and Investiční a poštovní banka, along with their total revenue, headquarters location, date of revenue (if available), net profit, profit margin (rounded to two decimal places), and the unit of revenue (if available)? Please order the results by ascending profit margin and limit the results to 20.

[Assistant]
I will search Wikidata for properties commonly used for "revenue" and "net profit", then search for companies headquartered in the Czech Republic and their revenue/net profit statements. I'll explain each search and query I run.

Question: revenue

Top 10 property alternatives:
1. total revenue (wd:P2139 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via revenue), also known as gross revenue, income, net sales, revenue, sales, etc.: income gained by an organization during a given time frame. Not to be confused with fiscal revenue
2. box office (wd:P2142 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via earnings), also known as earnings, P2142: box office takings accumulated by a film / is subproperty of total revenue
3. source of income (wd:P2770 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via revenue source), also known as income source, revenue source, source of revenue, P2770: source of income of an organization or person
4. fiscal/tax revenue (wd:P3087 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn), also known as P3087: fiscal revenue of a public entity (not for private entities)
5. units sold (wd:P2664 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via sales figures), also known as number of sales, sales, sales figures, total sales, P2664: is subproperty of quantity / sales figures of an object
6. net profit (wd:P2295 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via profit), also known as bottom line, clear gain, clear profit, net earnings, net income, etc.: private entity profit after accounting for all costs
7. operating income (wd:P3362 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn), also known as earnings before interest and taxes, EBIT, operating profit, P3362: private entity operating income
8. donations (wd:P8093 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via donations received), also known as donations received, P8093: sum of donations an organization receives
9. net worth (wd:P2218 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn), also known as declared patrimony, estimated net worth, net wealth, net worth estimate, personal assets, etc.: totality of wealth possessed by a person
10. quantity (wd:P1114 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via total), also known as amount, copies, count, instances, multiplicity, etc.: number of instances of this subject in the universe of the ... number of instances in Wikidata may be lower or higher) / number of instances of this subject

[Assistant]
Next I'll confirm the Wikidata item for "Czech Republic" and the properties for "headquarters location" and "net profit" / "total revenue" usage patterns. I'll search for the country entity and verify property identifiers. I'll explain the results.

Question: Czech Republic

Top 10 entity alternatives:
1. Czech Republic (wd:Q213), also known as CZ, CZE, Czechia, CZR: is instance of landlocked country / is instance of sovereign state / is instance of successor state / republic in Central Europe / country in Central Europe / is instance of Republic / is instance of republic / is instance of country / country in Europe
2. Czech Republic (wd:Q3496079): member state of the Czech and Slovak Federal Republic (1990–1992) / is instance of constituent republic within Czechoslovakia
3. Czech Republic (wd:Q5201764): is instance of constituency of the European Parliament / constituency of the European Parliament
4. Czech Republic (wd:Q103900680): is instance of encyclopaedic article / is instance of encyclopedia article / encyclopedia article
5. Czech Republic (wd:Q25339548): is instance of team / iGEM 2015 team
6. CZECH REPUBLIC (wd:Q60164570): is instance of scholarly article / is instance of academic article
7. Czech Republic (wd:Q59760445): scholarly article by LUKAS LINEK & ZDENKA MANSFELDOVA published December 2004 in European Journal of Political Research / is instance of scholarly article / is instance of academic article
8. Czech Republic (wd:Q57542866): is instance of scholarly article / is instance of academic article / scholarly article
9. Czech Republic (wd:Q59212257): scholarly article by Aleš Kudrnáč et al published December ... Journal of Political Research Political Data Yearbook / is instance of scholarly article / is instance of academic article
10. Czech Republic (wd:Q59212246): scholarly article by IVAN PETÚŠEK & ALEŠ KUDRNÁČ published 5 ... Journal of Political Research Political Data Yearbook / is instance of scholarly article / is instance of academic article

[Assistant]
I'll search for the properties "headquarters location", "total revenue", and "net profit" to confirm their property IDs and usage.

Question: headquarters location

Top 10 property alternatives:
1. headquarters location (wd:P159 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn), also known as admin HQ, based in, garrison, head office location, head quarters, etc.: city or town where an organization's headquarters is or has been situated. Use P276 qualifier for specific building / specific location where an organisation's HQ is or has been located / specific location where an organisation's HQ is or has been located / is subproperty of significant place
2. capital (wd:P36 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via administrative headquarters), also known as administrative capital, administrative center, administrative centre, administrative headquarters, administrative seat, etc.: location (city, municipality) of governmental seat of the country, or administrative territorial entity / seat of government of a country, province, state or other type of administrative territorial entity / city of governmental seat of the country, state or administrative subdivision
3. occupant (wd:P466 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via location of), also known as home team, houses, inhabitant, lessee, location of, etc.: person or organization occupying a building or facility / person or organization occupying property / is subproperty of used by
4. operating area (wd:P2541 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via place of operation), also known as area of operations, area of responsibility, area operated, area served, areas served, etc.: geographic area or jurisdiction an organisation or industry operates in, serves, or has responsibility for / geographic area or jurisdiction an organisation or industry operates in, serves, or has responsibility for / geographic area or jurisdiction an organization or industry operates in, serves, or has responsibility for / is subproperty of location
5. work location (wd:P937 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via location of work), also known as active in, conducts business at, conducts business in, did work at, did work from, etc.: location where persons or organisations were actively participating in employment, business or other work / is subproperty of significant place / location where persons were active / is subproperty of location
6. location of creation (wd:P1071 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via manufacturing location), also known as assembly location, built at, built in, composed at, created at, etc.: place where the item was conceived or made; where applicable, location of final assembly / is subproperty of significant place
7. applies to jurisdiction (wd:P1001 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via of location), also known as applicable area, applicable country, applicable geographic place, applicable jurisdiction, applicable location, etc.: the item (institution, law, public office, public ... jurisdiction: a country, state, municipality, ...) / the item (an institution, law, public office ...) or ... jurisdiction: a country, state, municipality, ...) / is subproperty of characteristic of / is subproperty of significant place / is subproperty of operating area
8. location of formation (wd:P740 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via place of establishment), also known as comes from, formation location, formation place, formed in, founded in, etc.: location where a group or organisation was formed / location where a group or organization was formed / is subproperty of location of creation
9. coordinates of geographic center (wd:P5140 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via geographical center), also known as coordinates of geographic centre, geographical center, geographical centre, geographical midpoint, geographic center, etc.: coordinates of the center of an area. Use qualifier "determination method" (P459) to indicate how / coordinates of the centre of an area. Use qualifier "determination method" (P459) to indicate how / is subproperty of coordinate location
10. coordinate location (wd:P625 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via location), also known as co-ordinate location, co-ordinates, coordinates, co-ords, coords, etc.: geocoordinates of the subject. For Earth, please note that only WGS84 coordinating system is supported at the moment / coordinates of the subject / coordinates of the subject

[Assistant]
I'll search for an appropriate class for "company/business" to filter items (e.g., "business", "company", "corporation"). I will verify the entity id to use in queries (e.g., instance of 'company' Q...). I'll explain the result.

Question: company

Top 10 entity alternatives:
1. company (wd:Q783794), also known as co., firm: legal entity representing an association of people, whether natural, legal or a mixture of both, with a specific objective / an organisation of people with a common purpose, such as a business / is instance of type of organization / is instance of type of organisation / is subclass of legal person / is subclass of organisation / is subclass of organization / is instance of legal form
2. company (wd:Q102538), also known as company (military unit), military company: is subclass of size-specific military unit / is instance of military unit size class / military unit size designation
3. enterprise (wd:Q6881511, matched via company), also known as business enterprise, company, firm: organizational unit producing goods or services, which ... especially for the allocation of its current resources / organizational unit producing goods or services, which ... especially for the allocation of its current resources / is instance of legal concept / is subclass of business
4. Company (wd:Q225093): 2002 film directed by Ram Gopal Varma / is instance of film
5. Company (wd:Q2915810): 1970 musical comedy by Stephen Sondheim / is instance of dramatico-musical work
6. Company (wd:Q23723998): is instance of musical work/composition / 2016 single by Justin Bieber
7. The Company (wd:Q681815, matched via Company), also known as Company: 2003 film by Robert Altman / is instance of film
8. Company (wd:Q5155503): 1979 short novel by Samuel Beckett / is instance of literary work
9. .company (wd:Q16048325): is instance of top-level domain / top-level domain
10. Manuel Compañy (wd:Q15876995, matched via Compañy), also known as Compañy: has occupation photographer / is instance of human / Spanish photographer / Spanish photographer / Spanish photographer

[Assistant]
I'll run a SPARQL SELECT to find entities that are instances (or subclasses) of "company" (wd:Q783794) and have a headquarters location (P159) whose country (P17) is the Czech Republic (wd:Q213). I'll retrieve labels to inspect sample companies and their HQs. I'll exclude the two company labels provided to avoid them showing up in sample.

execute

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?company ?companyLabel ?hq ?hqLabel WHERE {
  ?company wdt:P31/wdt:P279* wd:Q783794 .
  ?company wdt:P159 ?hq .
  ?hq wdt:P17 wd:Q213 .
  FILTER(?companyLabel NOT IN ("Adental Czech Republic", "Investiční a poštovní banka"))
  ?company rdfs:label ?companyLabel . FILTER(LANG(?companyLabel) = "en")
  ?hq rdfs:label ?hqLabel . FILTER(LANG(?hqLabel) = "en")
} LIMIT 50

Got 50 rows and 4 columns, showing the first 5 and last 5 rows below:
| company                                                                   | companyLabel                                                        | hq                      | hqLabel             |
| ------------------------------------------------------------------------- | ------------------------------------------------------------------- | ----------------------- | ------------------- |
| Amati Kraslice, Výrobní Družstvo (wd:Q116895647)                          | Amati Kraslice, Výrobní Družstvo (lang:en)                          | Kraslice (wd:Q1000029)  | Kraslice (lang:en)  |
| SAMETEX (wd:Q52856437)                                                    | SAMETEX (lang:en)                                                   | Kraslice (wd:Q1000029)  | Kraslice (lang:en)  |
| Pětihoří (wd:Q131310643)                                                  | Pětihoří (lang:en)                                                  | Kraslice (wd:Q1000029)  | Kraslice (lang:en)  |
| Městské kulturní centrum Kraslice, příspěvková organizace (wd:Q114672466) | Městské kulturní centrum Kraslice, příspěvková organizace (lang:en) | Kraslice (wd:Q1000029)  | Kraslice (lang:en)  |
| Lantal Parts (wd:Q67804243)                                               | Lantal Parts (lang:en)                                              | Kraslice (wd:Q1000029)  | Kraslice (lang:en)  |
| ...                                                                       | ...                                                                 | ...                     | ...                 |
| Wendell electronics (wd:Q67809224)                                        | Wendell electronics (lang:en)                                       | Lanškroun (wd:Q1000033) | Lanškroun (lang:en) |
| Stavební bytové družstvo Lanškroun (wd:Q67814593)                         | Stavební bytové družstvo Lanškroun (lang:en)                        | Lanškroun (wd:Q1000033) | Lanškroun (lang:en) |
| Orpa (wd:Q12042931)                                                       | Orpa (lang:en)                                                      | Lanškroun (wd:Q1000033) | Lanškroun (lang:en) |
| Soma Engineering (wd:Q18014900)                                           | Soma Engineering (lang:en)                                          | Lanškroun (wd:Q1000033) | Lanškroun (lang:en) |
| Vanko CZ (wd:Q130555290)                                                  | Vanko CZ (lang:en)                                                  | Lanškroun (wd:Q1000033) | Lanškroun (lang:en) |

[Assistant]
I'll search for "Škoda Auto" entity to inspect how revenue/net profit quantities are stored, so I can structure the query to extract units and qualifiers correctly.

Question: Škoda Auto

Top 10 entity alternatives:
1. Škoda Auto (wd:Q29637), also known as Automobilový koncern ŠKODA a.s., Skoda, SKODA, Skoda Auto, Škoda Auto a.s., etc.: automotive manufacturing subsidiary of Volkswagen Group / is instance of automobile manufacturer / is instance of car manufacturer / is instance of enterprise / is instance of business
2. Škoda Auto Museum (wd:Q3610511), also known as Škoda Muzeum (Mladá Boleslav, Česko): is instance of automobile museum / museum in Czech Republic
3. Škoda Auto University (wd:Q391945): private university located in Mladá Boleslav, Czech Republic / is instance of Czech research institution / is instance of organisation / is instance of organization / is instance of university
4. Škoda Auto Vrchlabí (wd:Q115858401): is instance of enterprise
5. Škoda Auto Deutschland (wd:Q18030153): is instance of business / Firm
6. Škoda Auto DigiLab (wd:Q64778156): is instance of enterprise / is instance of business / Czech company
7. Skoda Auto Volkswagen India (wd:Q7940322), also known as ŠAVWIPL, Škoda Auto Volkswagen India, ŠKODA AUTO Volkswagen India Pvt Ltd, Volkswagen Group Sales India: is instance of business / Indian company
8. Nadační fond Škoda Auto (wd:Q110756120): is instance of endowment fund / is instance of organization / is instance of organisation
9. ŠKODA AUTO University, Library (wd:Q114619605): is instance of university library / is instance of college library
10. Škoda Autohaus Eschwege (wd:Q83866514): Škoda Autohaus der Glinicke Automobilgruppe / is instance of business

[Assistant]
I'll query the revenue (P2139) statements for Škoda Auto to see how values, units, and point-in-time qualifiers are represented.

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?stmt ?revValue ?revUnit ?revDate ?revValueLabel WHERE {
  wd:Q29637 p:P2139 ?stmt .
  ?stmt ps:P2139 ?revValue .
  OPTIONAL { ?stmt pq:P585 ?revDate }
  OPTIONAL { ?stmt psn:P2139 ?revValueLabel }
  OPTIONAL { ?revValue wikibase:quantityUnit ?revUnit }
} LIMIT 50

[Assistant]
I'll query the statement value node (psv) for P2139 on Škoda Auto to retrieve the quantity node's amount and unit using wikibase:quantityAmount and wikibase:quantityUnit. I'll show the statement node, amount, unit, and unit label to inspect units.

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?stmt ?amount ?unit ?unitLabel ?date WHERE {
  wd:Q29637 p:P2139 ?stmt .
  ?stmt psv:P2139 ?valueNode .
  ?valueNode wikibase:quantityAmount ?amount .
  OPTIONAL { ?valueNode wikibase:quantityUnit ?unit .
             ?unit rdfs:label ?unitLabel . FILTER(LANG(?unitLabel) = "en") }
  OPTIONAL { ?stmt pq:P585 ?date }
} LIMIT 50

[Assistant]
I'll search for the two companies to exclude so I can use their exact Wikidata QIDs in the query filters.

Question: Adental Czech Republic

Top 10 entity alternatives:
1. Adental Czech Republic (wd:Q100707321): is instance of business / Czech medical company
2. Czech Republic (wd:Q213), also known as CZ, CZE, Czechia, CZR: is instance of landlocked country / is instance of successor state / is instance of sovereign state / republic in Central Europe / country in Central Europe / is instance of Republic / is instance of republic / is instance of country / country in Europe
3. flag of the Czech Republic (wd:Q127155, matched via Czech Republic flag), also known as Czech flag, Czech Republic flag, flag of Czechia, flag of Czechoslovakia, the Czech Republic flag: national flag of the Czech Republic / is instance of national flag
4. Jihlava (wd:Q183111, matched via Jihlava, Czech Republic), also known as Iglau, Jihlava, Czech Republic, Jihlava, Vysocina: is instance of municipality with town privileges in the Czech Republic / is instance of municipality with authorized municipal office / is instance of Czech municipality with expanded powers / is instance of municipality of the Czech Republic / is instance of statutory city in Czechia / is instance of capital of region / city in Vysocina, Czech Republic / is instance of mining community / is instance of district town
5. geography of the Czech Republic (wd:Q76380, matched via Czech Republic geography), also known as Czech Republic geography, the Czech Republic geography: is instance of geography of geographic location / is subclass of geography of Europe / features of Czechia
6. Army of the Czech Republic (wd:Q276325, matched via mil Czech Republic), also known as Armady Ceske, Armed Forces of the Czech Republic, Czech Armed Forces, Czech military, Czech Military, etc.: combined military forces of the Czech Republic / is instance of armed forces / is instance of Armed forces
7. Javorek (wd:Q72366, matched via Javorek, Czech Republic), also known as Javorek, Czech Republic: village in Žďár nad Sázavou District of Vysočina region / is instance of municipality of the Czech Republic
8. Mirotice (wd:Q1641811, matched via Mirotice, Czech Republic), also known as Mirotice, Czech Republic: is instance of municipality with town privileges in the Czech Republic / is instance of municipality with authorized municipal office / is instance of municipality of the Czech Republic / municipality of the Czech Republic
9. Jezernice (wd:Q1632309, matched via Jezernice, Czech Republic), also known as Jezernice, Czech Republic: is instance of municipality of the Czech Republic / village in Přerov District of Olomouc region
10. Sulice (wd:Q2239471, matched via Sulice, Czech Republic), also known as Sulice, Czech Republic: village in Praha-východ District of Central Bohemian region, Czech Republic / is instance of municipality of the Czech Republic

[Assistant]
Search for the other company next. (I'll continue to the next function call.)

Question: Investiční a poštovní banka

Top 10 entity alternatives:
1. Investiční a poštovní banka (wd:Q12021780), also known as Investiční banka, IPB: is instance of former entity / is instance of enterprise / governmental organization / is instance of business / is instance of Bank / is instance of bank / former Czech bank
2. STING Realitní a investiční skupina (wd:Q130557405, matched via STING Realitní a investiční skupina a.s.), also known as STING Realitní a investiční skupina a.s.: is instance of enterprise / is instance of business / Czech company
3. Novinová a poštovní (wd:Q106586580): is instance of business
4. Investiční a majetková (wd:Q67810899): is instance of enterprise / is instance of business / Czech company
5. Stavební, investiční a kapitálová (wd:Q67804080): is instance of enterprise / is instance of business / Czech company
6. Poštovní banka (wd:Q61640132): is instance of enterprise / is instance of business / former Czech bank
7. Census of India 2011 (Bihar): Banka District Village and Town Directory (wd:Q55971546, matched via DCHB Banka Part A), also known as DCHB Banka Part A: is instance of report
8. Komerční banka (wd:Q1541079, matched via Komerční banka, a.s.), also known as KB, Komerční banka, a.s.: banking company in the Czech Republic / is instance of credit institution / is instance of investment firm / is instance of enterprise / is instance of business / is instance of company / is instance of bank / is instance of Bank
9. Československá obchodní banka (wd:Q340135, matched via Československá obchodní banka, a. s.), also known as Československá obchodní banka, a. s., ČSOB, Czechoslovak Commercial Bank: is instance of investment firm / commercial bank in Czechia / is instance of enterprise / is instance of business / is instance of company / is instance of bank / is instance of Bank
10. Tatra banka (wd:Q1718069, matched via Tatra banka, a.s.), also known as Tatra bank, Tatra banka, a.s., TB: commercial bank located in Slovakia / is instance of credit institution / is instance of enterprise / is instance of business / is instance of Bank / is instance of bank

[Assistant]
I'll run a SPARQL query that:
- finds entities that are instances/subclasses of "company" and have headquarters in a place whose country is the Czech Republic,
- excludes the two specified companies by QID,
- selects the most recent revenue (P2139) statement and the most recent net profit (P2295) statement per company,
- obtains amounts, units (for revenue), and point-in-time qualifiers (dates),
- computes profit margin as (net / revenue) * 100 and rounds it to two decimal places,
- orders results by ascending profit margin and limits to 20.

Now I'll execute that query. I'll show the SPARQL I run next.

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?company ?companyLabel ?hq ?hqLabel ?revAmount ?revUnitLabel ?revDate ?netAmount ?netDate ?profitMargin WHERE {
  ?company wdt:P31/wdt:P279* wd:Q783794 .
  ?company wdt:P159 ?hq .
  ?hq wdt:P17 wd:Q213 .
  FILTER(?company NOT IN (wd:Q100707321, wd:Q12021780))
  ?company rdfs:label ?companyLabel . FILTER(LANG(?companyLabel) = "en")
  ?hq rdfs:label ?hqLabel . FILTER(LANG(?hqLabel) = "en")

  {
    SELECT ?company ?revAmount ?revUnit ?revDate WHERE {
      ?company p:P2139 ?revStmt .
      ?revStmt psv:P2139 ?revValNode .
      ?revValNode wikibase:quantityAmount ?revAmount .
      OPTIONAL { ?revValNode wikibase:quantityUnit ?revUnit }
      OPTIONAL { ?revStmt pq:P585 ?revDate }
    } ORDER BY DESC(?revDate) LIMIT 1
  }
  OPTIONAL { ?revUnit rdfs:label ?revUnitLabel FILTER(LANG(?revUnitLabel) = "en") }

  {
    SELECT ?company ?netAmount ?netDate WHERE {
      ?company p:P2295 ?netStmt .
      ?netStmt psv:P2295 ?netValNode .
      ?netValNode wikibase:quantityAmount ?netAmount .
      OPTIONAL { ?netStmt pq:P585 ?netDate }
    } ORDER BY DESC(?netDate) LIMIT 1
  }

  FILTER(?revAmount != 0)
  BIND((?netAmount / ?revAmount) * 100 AS ?profitMarginRaw)
  BIND((ROUND(?profitMarginRaw * 100) / 100) AS ?profitMargin)
}
ORDER BY ?profitMargin
LIMIT 20

[Assistant]
I will retry with a query that (a) allows companies that either have P17 = Czech Republic or have a headquarters location (P159) whose place or administrative parent is in the Czech Republic, and (b) makes the headquarters label optional (so companies without P159 are still included). Then I will re-run the revenue/net-profit subselects and compute profit margin as before. I'll execute that adjusted query now.

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?company ?companyLabel ?hq ?hqLabel ?revAmount ?revUnitLabel ?revDate ?netAmount ?netDate ?profitMargin WHERE {
  ?company wdt:P31/wdt:P279* wd:Q783794 .
  OPTIONAL { ?company wdt:P159 ?hq . ?hq rdfs:label ?hqLabel . FILTER(LANG(?hqLabel) = "en") }
  ?company rdfs:label ?companyLabel . FILTER(LANG(?companyLabel) = "en")
  FILTER(?company NOT IN (wd:Q100707321, wd:Q12021780))

  # Ensure the company is associated with the Czech Republic either directly (P17) or via HQ (P159 -> P17) or via HQ admin chain (P159 -> P131* -> P17)
  FILTER(
    EXISTS { ?company wdt:P17 wd:Q213 } ||
    EXISTS { ?company wdt:P159 ?hq2 . ?hq2 wdt:P17 wd:Q213 } ||
    EXISTS { ?company wdt:P159 ?hq3 . ?hq3 wdt:P131* ?admin . ?admin wdt:P17 wd:Q213 }
  )

  {
    SELECT ?company ?revAmount ?revUnit ?revDate WHERE {
      ?company p:P2139 ?revStmt .
      ?revStmt psv:P2139 ?revValNode .
      ?revValNode wikibase:quantityAmount ?revAmount .
      OPTIONAL { ?revValNode wikibase:quantityUnit ?revUnit }
      OPTIONAL { ?revStmt pq:P585 ?revDate }
    } ORDER BY DESC(?revDate) LIMIT 1
  }
  OPTIONAL { ?revUnit rdfs:label ?revUnitLabel FILTER(LANG(?revUnitLabel) = "en") }

  {
    SELECT ?company ?netAmount ?netDate WHERE {
      ?company p:P2295 ?netStmt .
      ?netStmt psv:P2295 ?netValNode .
      ?netValNode wikibase:quantityAmount ?netAmount .
      OPTIONAL { ?netStmt pq:P585 ?netDate }
    } ORDER BY DESC(?netDate) LIMIT 1
  }

  FILTER(?revAmount != 0)
  BIND((?netAmount / ?revAmount) * 100 AS ?profitMarginRaw)
  BIND((ROUND(?profitMarginRaw * 100) / 100) AS ?profitMargin)
}
ORDER BY ?profitMargin
LIMIT 20

[Assistant]
I'll run a small check to see if Škoda Auto (wd:Q29637) has P2295 net profit statements. This will help confirm whether many Czech companies have net profit recorded.

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?stmt ?amount ?unit ?date WHERE {
  wd:Q29637 p:P2295 ?stmt .
  ?stmt psv:P2295 ?val .
  ?val wikibase:quantityAmount ?amount .
  OPTIONAL { ?val wikibase:quantityUnit ?unit . ?unit rdfs:label ?unitLabel . FILTER(LANG(?unitLabel) = "en") }
  OPTIONAL { ?stmt pq:P585 ?date }
} LIMIT 20

[Assistant]
(I'm going to run a smaller query that finds companies with both P2139 and P2295 and that have country or HQ in Czech Republic, but I'll make labels optional so lack of English labels doesn't filter them out.)

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?company WHERE {
  ?company wdt:P31/wdt:P279* wd:Q783794 .
  FILTER(?company NOT IN (wd:Q100707321, wd:Q12021780))
  # country or HQ in Czech
  FILTER(
    EXISTS { ?company wdt:P17 wd:Q213 } ||
    EXISTS { ?company wdt:P159 ?hq2 . ?hq2 wdt:P17 wd:Q213 } ||
    EXISTS { ?company wdt:P159 ?hq3 . ?hq3 wdt:P131* ?admin . ?admin wdt:P17 wd:Q213 }
  )
  # must have revenue and net profit statements
  FILTER EXISTS { ?company p:P2139 ?revStmt . }
  FILTER EXISTS { ?company p:P2295 ?netStmt . }
} LIMIT 50

Got 50 rows and 1 column, showing the first 5 and last 5 rows below:
| company                               |
| ------------------------------------- |
| Praha West Investment (wd:Q100148340) |
| Praha West Investment (wd:Q100148340) |
| Budweiser Budvar (wd:Q1001644)        |
| Budweiser Budvar (wd:Q1001644)        |
| Geneea Analytics (wd:Q100250403)      |
| ...                                   |
| Vestar Group (wd:Q106526415)          |
| Letiště Vodochody (wd:Q106595818)     |
| Silnice Morava (wd:Q106603450)        |
| Penta Hospitals CZ (wd:Q106671960)    |
| Elektrárna Počerady (wd:Q106715385)   |

[Assistant]
I will execute the adjusted query now; it allows missing English labels (they're optional) and checks company-country association via P17 or P159->P17 / P159->P131*->P17. Then it takes the most recent revenue and net profit statements per company and computes the profit margin.

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?company ?companyLabel ?hq ?hqLabel ?revAmount ?revUnitLabel ?revDate ?netAmount ?netDate ?profitMargin WHERE {
  ?company wdt:P31/wdt:P279* wd:Q783794 .
  FILTER(?company NOT IN (wd:Q100707321, wd:Q12021780))
  FILTER(
    EXISTS { ?company wdt:P17 wd:Q213 } ||
    EXISTS { ?company wdt:P159 ?hq2 . ?hq2 wdt:P17 wd:Q213 } ||
    EXISTS { ?company wdt:P159 ?hq3 . ?hq3 wdt:P131* ?admin . ?admin wdt:P17 wd:Q213 }
  )
  OPTIONAL { ?company wdt:P159 ?hq . ?hq rdfs:label ?hqLabel FILTER(LANG(?hqLabel) = "en") }
  OPTIONAL { ?company rdfs:label ?companyLabel FILTER(LANG(?companyLabel) = "en") }

  {
    SELECT ?company ?revAmount ?revUnit ?revDate WHERE {
      ?company p:P2139 ?revStmt .
      ?revStmt psv:P2139 ?revValNode .
      ?revValNode wikibase:quantityAmount ?revAmount .
      OPTIONAL { ?revValNode wikibase:quantityUnit ?revUnit }
      OPTIONAL { ?revStmt pq:P585 ?revDate }
    } ORDER BY DESC(?revDate) LIMIT 1
  }
  OPTIONAL { ?revUnit rdfs:label ?revUnitLabel FILTER(LANG(?revUnitLabel) = "en") }

  {
    SELECT ?company ?netAmount ?netDate WHERE {
      ?company p:P2295 ?netStmt .
      ?netStmt psv:P2295 ?netValNode .
      ?netValNode wikibase:quantityAmount ?netAmount .
      OPTIONAL { ?netStmt pq:P585 ?netDate }
    } ORDER BY DESC(?netDate) LIMIT 1
  }

  FILTER(?revAmount != 0)
  BIND((?netAmount / ?revAmount) * 100 AS ?profitMarginRaw)
  BIND((ROUND(?profitMarginRaw * 100) / 100) AS ?profitMargin)
}
ORDER BY ?profitMargin
LIMIT 20

[Assistant]
I'll try a different approach: join revenue and net profit statements that share the same point-in-time qualifier (pq:P585). This picks revenue/net pairs for the same date. I'll retrieve unit for revenue if present, compute profit margin, and filter companies to be in the Czech Republic (P17 or HQ chain). I will not require English labels (they're optional). I'll run that query now.

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?company ?companyLabel ?hq ?hqLabel ?revAmount ?revUnitLabel ?date ?netAmount ?profitMargin WHERE {
  ?company wdt:P31/wdt:P279* wd:Q783794 .
  FILTER(?company NOT IN (wd:Q100707321, wd:Q12021780))
  OPTIONAL { ?company wdt:P159 ?hq . ?hq rdfs:label ?hqLabel FILTER(LANG(?hqLabel) = "en") }
  OPTIONAL { ?company rdfs:label ?companyLabel FILTER(LANG(?companyLabel) = "en") }

  # country/HQ filter
  FILTER(
    EXISTS { ?company wdt:P17 wd:Q213 } ||
    EXISTS { ?company wdt:P159 ?hq2 . ?hq2 wdt:P17 wd:Q213 } ||
    EXISTS { ?company wdt:P159 ?hq3 . ?hq3 wdt:P131* ?admin . ?admin wdt:P17 wd:Q213 }
  )

  # revenue and net profit statements sharing same point-in-time date
  ?company p:P2139 ?revStmt .
  ?revStmt psv:P2139 ?revValNode .
  ?revValNode wikibase:quantityAmount ?revAmount .
  OPTIONAL { ?revValNode wikibase:quantityUnit ?revUnit . ?revUnit rdfs:label ?revUnitLabel FILTER(LANG(?revUnitLabel) = "en") }
  ?revStmt pq:P585 ?date .

  ?company p:P2295 ?netStmt .
  ?netStmt psv:P2295 ?netValNode .
  ?netValNode wikibase:quantityAmount ?netAmount .
  ?netStmt pq:P585 ?date .

  FILTER(?revAmount != 0)
  BIND((?netAmount / ?revAmount) * 100 AS ?profitMarginRaw)
  BIND((ROUND(?profitMarginRaw * 100) / 100) AS ?profitMargin)
}
ORDER BY ?profitMargin
LIMIT 20

Got 20 rows and 9 columns, showing the first 5 and last 5 rows below:
| company                              | companyLabel                    | hq                | hqLabel          | revAmount             | revUnitLabel           | date                                | netAmount                 | profitMargin           |
| ------------------------------------ | ------------------------------- | ----------------- | ---------------- | --------------------- | ---------------------- | ----------------------------------- | ------------------------- | ---------------------- |
| CITIC Europe Holdings (wd:Q47466468) | CITIC Europe Holdings (lang:en) | Prague (wd:Q1085) | Prague (lang:en) | 1092000 (xsd:decimal) | Czech koruna (lang:en) | 2018-01-01T00:00:00Z (xsd:dateTime) | -5403679000 (xsd:decimal) | -494842 (xsd:decimal)  |
| CITIC Europe Holdings (wd:Q47466468) | CITIC Europe Holdings (lang:en) | Prague (wd:Q1085) | Prague (lang:en) | 1092000 (xsd:decimal) | Czech koruna (lang:en) | 2018-01-01T00:00:00Z (xsd:dateTime) | -5403679000 (xsd:decimal) | -494842 (xsd:decimal)  |
| CITIC Europe Holdings (wd:Q47466468) | CITIC Europe Holdings (lang:en) | Prague (wd:Q1085) | Prague (lang:en) | 1092000 (xsd:decimal) | Czech koruna (lang:en) | 2018-01-01T00:00:00Z (xsd:dateTime) | -4725729000 (xsd:decimal) | -432759 (xsd:decimal)  |
| CITIC Europe Holdings (wd:Q47466468) | CITIC Europe Holdings (lang:en) | Prague (wd:Q1085) | Prague (lang:en) | 1092000 (xsd:decimal) | Czech koruna (lang:en) | 2018-01-01T00:00:00Z (xsd:dateTime) | -4725729000 (xsd:decimal) | -432759 (xsd:decimal)  |
| CITIC Europe Holdings (wd:Q47466468) | CITIC Europe Holdings (lang:en) | Prague (wd:Q1085) | Prague (lang:en) | 49000 (xsd:decimal)   | Czech koruna (lang:en) | 2015-01-01T00:00:00Z (xsd:dateTime) | -119986000 (xsd:decimal)  | -244869 (xsd:decimal)  |
| ...                                  | ...                             | ...               | ...              | ...                   | ...                    | ...                                 | ...                       | ...                    |
| Magna Energy Storage (wd:Q58875490)  | Magna Energy Storage (lang:en)  | Prague (wd:Q1085) | Prague (lang:en) | 761000 (xsd:decimal)  | Czech koruna (lang:en) | 2020-01-01T00:00:00Z (xsd:dateTime) | -57802000 (xsd:decimal)   | -7595.53 (xsd:decimal) |
| Magna Energy Storage (wd:Q58875490)  | Magna Energy Storage (lang:en)  | Prague (wd:Q1085) | Prague (lang:en) | 761000 (xsd:decimal)  | Czech koruna (lang:en) | 2020-01-01T00:00:00Z (xsd:dateTime) | -57802000 (xsd:decimal)   | -7595.53 (xsd:decimal) |
| Xixoio (wd:Q110000079)               | Xixoio (lang:en)                | Prague (wd:Q1085) | Prague (lang:en) | 260000 (xsd:decimal)  | Czech koruna (lang:en) | 2019-01-01T00:00:00Z (xsd:dateTime) | -11220000 (xsd:decimal)   | -4315.38 (xsd:decimal) |
| Xixoio (wd:Q110000079)               | Xixoio (lang:en)                | Prague (wd:Q1085) | Prague (lang:en) | 260000 (xsd:decimal)  | Czech koruna (lang:en) | 2019-01-01T00:00:00Z (xsd:dateTime) | -11220000 (xsd:decimal)   | -4315.38 (xsd:decimal) |
| Warhorse Studios (wd:Q7969414)       | Warhorse Studios (lang:en)      | Prague (wd:Q1085) | Prague (lang:en) | 1130000 (xsd:decimal) | Czech koruna (lang:en) | 2016-01-01T00:00:00Z (xsd:dateTime) | -26483000 (xsd:decimal)   | -2343.63 (xsd:decimal) |

[Assistant]
answer

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?company ?companyLabel ?hq ?hqLabel ?revAmount ?revUnitLabel ?date ?netAmount ?profitMargin WHERE {
  ?company wdt:P31/wdt:P279* wd:Q783794 .
  FILTER(?company NOT IN (wd:Q100707321, wd:Q12021780))
  OPTIONAL { ?company wdt:P159 ?hq . ?hq rdfs:label ?hqLabel FILTER(LANG(?hqLabel) = "en") }
  OPTIONAL { ?company rdfs:label ?companyLabel FILTER(LANG(?companyLabel) = "en") }

  FILTER(
    EXISTS { ?company wdt:P17 wd:Q213 } ||
    EXISTS { ?company wdt:P159 ?hq2 . ?hq2 wdt:P17 wd:Q213 } ||
    EXISTS { ?company wdt:P159 ?hq3 . ?hq3 wdt:P131* ?admin . ?admin wdt:P17 wd:Q213 }
  )

  ?company p:P2139 ?revStmt .
  ?revStmt psv:P2139 ?revValNode .
  ?revValNode wikibase:quantityAmount ?revAmount .
  OPTIONAL { ?revValNode wikibase:quantityUnit ?revUnit . ?revUnit rdfs:label ?revUnitLabel FILTER(LANG(?revUnitLabel) = "en") }
  ?revStmt pq:P585 ?date .

  ?company p:P2295 ?netStmt .
  ?netStmt psv:P2295 ?netValNode .
  ?netValNode wikibase:quantityAmount ?netAmount .
  ?netStmt pq:P585 ?date .

  FILTER(?revAmount != 0)
  BIND((?netAmount / ?revAmount) * 100 AS ?profitMarginRaw)
  BIND((ROUND(?profitMarginRaw * 100) / 100) AS ?profitMargin)
}
ORDER BY ?profitMargin
LIMIT 20

Answer:
I ran a query that returns up to 20 companies (instances/subclasses of "company") associated with the Czech Republic (via P17 or via headquarters P159 / admin chain) excluding Adental Czech Republic (wd:Q100707321) and Investiční a poštovní banka (wd:Q12021780). For each company it returns:
- company (IRI) and optional English label,
- headquarters (IRI) and optional English label,
- a revenue amount (psv:P2139 wikibase:quantityAmount), the revenue unit label when available (from the quantity unit), and the point-in-time date (pq:P585) for that revenue statement,
- a net profit amount (psv:P2295 wikibase:quantityAmount) for a net profit statement with the same point-in-time date,
- the profit margin computed as (net / revenue) * 100 and rounded to two decimal places.

Important notes about the returned data (observations from the query results):
- The query pairs revenue and net-profit statements that share the same pq:P585 qualifier (the same point-in-time). Only pairs with matching dates are included.
- Units are shown when the revenue quantity node has a wikibase:quantityUnit; many monetary values use the Czech koruna unit when present.
- Some rows may show very large or very negative profit margins because the raw amounts in Wikidata may be recorded at different scales or reflect losses; the query uses the literal numeric amounts as stored.
- The query returns the actual Wikidata IRIs (identifiers) for companies and headquarters as requested.

If you want:
- I can refine the pairing logic to choose the most recent revenue and net-profit values per company (even when dates do not match),
- or normalize currencies/units where possible (e.g., convert to a common currency) — note that currency conversion would require external exchange rate data.

Below is the SPARQL I executed (same as above).