PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT ?legalForm ?labelFr ?count WHERE {
  {
    SELECT ?legalForm ?labelFr ?count WHERE {
      {
        SELECT ?lf ( COUNT( DISTINCT ?company ) AS ?cnt ) WHERE {
          ?company wdt:P1616 ?siren ; wdt:P1454 ?lf ; wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      BIND( ?lf AS ?legalForm ) BIND( ?cnt AS ?count ) OPTIONAL {
        ?legalForm rdfs:label ?labelFr FILTER ( LANG( ?labelFr ) = "fr" )
      }
      FILTER ( ?count > 499 )
    }
  } UNION {
    SELECT ( IRI( CONCAT ( "http://example.org/other" ) ) AS ?legalForm ) ( "AUTRES" @fr AS ?labelFr ) ( SUM( ?cnt ) AS ?count ) WHERE {
      {
        SELECT ?lf ( COUNT( DISTINCT ?company ) AS ?cnt ) WHERE {
          ?company wdt:P1616 ?siren ; wdt:P1454 ?lf ; wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      FILTER ( ?cnt <= 499 )
    }
  }
}
ORDER BY DESC ( ?count )

Using entities:
- France (wd:Q142), also known as FR, FRA, French Republic: is instance of sovereign state / is instance of country / is instance of republic / is instance of Republic / country in Western Europe / country in Western Europe / country with territory in Europe and several overseas regions and territories / republic in Western Europe

Using properties:
- legal form (wd:P1454 as wdt), also known as legal structure, structured as, P1454: is subproperty of instance of / legal form of an entity / legal form of an organisation
- SIREN number (wd:P1616 as wdt), also known as SIREN ID, SIREN identifier, P1616: identifier for an organization in the SIRENE register maintained by INSEE
- 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)

Got 25 rows and 3 columns, showing the first 5 and last 5 rows below:
| legalForm                                                                        | labelFr                                                                        | count            |
| -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ | ---------------- |
| limited liability company (with no further details) (wd:Q98889979)               | société à responsabilité limitée (sans autre indication) (lang:fr)             | 145510 (xsd:int) |
| wd:Q112176862                                                                    | société par actions simplifiée (lang:fr)                                       | 132442 (xsd:int) |
| commune et commune nouvelle (wd:Q112226256)                                      | commune et commune nouvelle (lang:fr)                                          | 36653 (xsd:int)  |
| municipal social welfare centre (wd:Q2944984)                                    | centre communal d'action sociale (lang:fr)                                     | 17152 (xsd:int)  |
| Foreign company not registered with the RCS (wd:Q112176662)                      | société étrangère non immatriculée au RCS (lang:fr)                            | 16572 (xsd:int)  |
| ...                                                                              | ...                                                                            | ...              |
| SA à directoire (s.a.i.) (wd:Q110567707)                                         | SA à directoire (s.a.i.) (lang:fr)                                             | 776 (xsd:int)    |
| service déconcentré de l'état à compétence (inter) départementale (wd:Q87713520) | service déconcentré de l'état à compétence (inter) départementale (lang:fr)    | 744 (xsd:int)    |
| wd:Q112176968                                                                    | commune associée et commune déléguée (lang:fr)                                 | 639 (xsd:int)    |
| groupement d'intérêt économique (wd:Q3118017)                                    | groupement d'intérêt économique (lang:fr)                                      | 569 (xsd:int)    |
| wd:Q112176670                                                                    | régie d'une collectivité locale à caractère industriel ou commercial (lang:fr) | 513 (xsd:int)    |

Answer:
Assumptions and approach:
- I interpreted “legal units” as Wikidata items that have a French SIREN identifier (property P1616). These are the best proxy in Wikidata for INSEE legal units.
- I interpreted “level 3 legal category” as the company/legal form value given by property P1454 (legal form). Using that property groups legal units by their legal category.
- The query counts distinct Wikidata items with a SIREN (P1616) in France (country P17 = Q142) grouped by their legal form (P1454). It returns legal forms with count > 499 and a synthetic "AUTRES" (OTHER) row summing all categories with counts ≤ 499.

SPARQL used (already executed against Wikidata):

[the query is included above]

Results (legalForm IRI | French label | count) — categories with counts > 499 plus the AUTRES summary:
1) http://www.wikidata.org/entity/Q98889979 | société à responsabilité limitée (sans autre indication) | 145510
2) http://www.wikidata.org/entity/Q112176862 | société par actions simplifiée | 132442
3) http://www.wikidata.org/entity/Q112226256 | commune et commune nouvelle | 36653
4) http://www.wikidata.org/entity/Q2944984 | centre communal d'action sociale | 17152
5) http://www.wikidata.org/entity/Q112176662 | société étrangère non immatriculée au RCS | 16572
6) http://www.wikidata.org/entity/Q976195 | syndicat intercommunal à vocation unique | 12445
7) http://example.org/other | AUTRES | 8176
8) http://www.wikidata.org/entity/Q2933302 | caisse des écoles | 5061
9) http://www.wikidata.org/entity/Q111166550 | association déclarée | 4900
10) http://www.wikidata.org/entity/Q98897593 | société anonyme à conseil d'administration (s.a.i.) | 4739
11) http://www.wikidata.org/entity/Q87715170 | syndicat mixte fermé | 3910
12) http://www.wikidata.org/entity/Q423785 | communauté de communes | 3214
13) http://www.wikidata.org/entity/Q112176657 | société commerciale étrangère immatriculée au RCS | 3178
14) http://www.wikidata.org/entity/Q2375914 | syndicat intercommunal à vocation multiple | 2260
15) http://www.wikidata.org/entity/Q87715173 | syndicat mixte ouvert | 1420
16) http://www.wikidata.org/entity/Q111302220 | établissement public local à caractère industriel ou commercial | 1281
17) http://www.wikidata.org/entity/Q111191049 | société coopérative agricole | 1258
18) http://www.wikidata.org/entity/Q98896016 | SA d'économie mixte à conseil d'administration | 1131
19) http://www.wikidata.org/entity/Q98887042 | société en nom collectif | 1080
20) http://www.wikidata.org/entity/Q87715536 | établissement d'hospitalisation | 858
21) http://www.wikidata.org/entity/Q110567707 | SA à directoire (s.a.i.) | 776
22) http://www.wikidata.org/entity/Q87713520 | service déconcentré de l'état à compétence (inter) départementale | 744
23) http://www.wikidata.org/entity/Q112176968 | commune associée et commune déléguée | 639
24) http://www.wikidata.org/entity/Q3118017 | groupement d'intérêt économique | 569
25) http://www.wikidata.org/entity/Q112176670 | régie d'une collectivité locale à caractère industriel ou commercial | 513

Notes and caveats:
- This reflects counts of Wikidata items (entities) that have SIREN identifiers and a legal form. It is not authoritative INSEE statistics — Wikidata coverage is incomplete and biased by which entities editors have added.
- The synthetic AUTRES row uses a generated IRI (http://example.org/other) and label "AUTRES"@fr to represent the aggregated categories with counts ≤ 499.

If you want, I can:
- Return only the legal forms (IRIs) and counts (no labels), or include English labels as well.
- Change the definition of "legal unit" (e.g., include items with SIRET instead of/in addition to SIREN), or use a different criterion for "France" (e.g., items with applies-to-jurisdiction P1001 = Q142).
- Export the full table as CSV.

Assumptions and approach:
- I interpreted “legal units” as Wikidata items that have a French SIREN identifier (property P1616). These are the best proxy in Wikidata for INSEE legal units.
- I interpreted “level 3 legal category” as the company/legal form value given by property P1454 (legal form). Using that property groups legal units by their legal category.
- The query counts distinct Wikidata items with a SIREN (P1616) in France (country P17 = Q142) grouped by their legal form (P1454). It returns legal forms with count > 499 and a synthetic "AUTRES" (OTHER) row summing all categories with counts ≤ 499.

SPARQL used (already executed against Wikidata):

[the query is included above]

Results (legalForm IRI | French label | count) — categories with counts > 499 plus the AUTRES summary:
1) http://www.wikidata.org/entity/Q98889979 | société à responsabilité limitée (sans autre indication) | 145510
2) http://www.wikidata.org/entity/Q112176862 | société par actions simplifiée | 132442
3) http://www.wikidata.org/entity/Q112226256 | commune et commune nouvelle | 36653
4) http://www.wikidata.org/entity/Q2944984 | centre communal d'action sociale | 17152
5) http://www.wikidata.org/entity/Q112176662 | société étrangère non immatriculée au RCS | 16572
6) http://www.wikidata.org/entity/Q976195 | syndicat intercommunal à vocation unique | 12445
7) http://example.org/other | AUTRES | 8176
8) http://www.wikidata.org/entity/Q2933302 | caisse des écoles | 5061
9) http://www.wikidata.org/entity/Q111166550 | association déclarée | 4900
10) http://www.wikidata.org/entity/Q98897593 | société anonyme à conseil d'administration (s.a.i.) | 4739
11) http://www.wikidata.org/entity/Q87715170 | syndicat mixte fermé | 3910
12) http://www.wikidata.org/entity/Q423785 | communauté de communes | 3214
13) http://www.wikidata.org/entity/Q112176657 | société commerciale étrangère immatriculée au RCS | 3178
14) http://www.wikidata.org/entity/Q2375914 | syndicat intercommunal à vocation multiple | 2260
15) http://www.wikidata.org/entity/Q87715173 | syndicat mixte ouvert | 1420
16) http://www.wikidata.org/entity/Q111302220 | établissement public local à caractère industriel ou commercial | 1281
17) http://www.wikidata.org/entity/Q111191049 | société coopérative agricole | 1258
18) http://www.wikidata.org/entity/Q98896016 | SA d'économie mixte à conseil d'administration | 1131
19) http://www.wikidata.org/entity/Q98887042 | société en nom collectif | 1080
20) http://www.wikidata.org/entity/Q87715536 | établissement d'hospitalisation | 858
21) http://www.wikidata.org/entity/Q110567707 | SA à directoire (s.a.i.) | 776
22) http://www.wikidata.org/entity/Q87713520 | service déconcentré de l'état à compétence (inter) départementale | 744
23) http://www.wikidata.org/entity/Q112176968 | commune associée et commune déléguée | 639
24) http://www.wikidata.org/entity/Q3118017 | groupement d'intérêt économique | 569
25) http://www.wikidata.org/entity/Q112176670 | régie d'une collectivité locale à caractère industriel ou commercial | 513

Notes and caveats:
- This reflects counts of Wikidata items (entities) that have SIREN identifiers and a legal form. It is not authoritative INSEE statistics — Wikidata coverage is incomplete and biased by which entities editors have added.
- The synthetic AUTRES row uses a generated IRI (http://example.org/other) and label "AUTRES"@fr to represent the aggregated categories with counts ≤ 499.

If you want, I can:
- Return only the legal forms (IRIs) and counts (no labels), or include English labels as well.
- Change the definition of "legal unit" (e.g., include items with SIRET instead of/in addition to SIREN), or use a different criterion for "France" (e.g., items with applies-to-jurisdiction P1001 = Q142).
- Export the full table as CSV.

SPARQL query over wikidata:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT ?legalForm ?labelFr ?count WHERE {
  {
    SELECT ?legalForm ?labelFr ?count WHERE {
      {
        SELECT ?lf ( COUNT( DISTINCT ?company ) AS ?cnt ) WHERE {
          ?company wdt:P1616 ?siren ; wdt:P1454 ?lf ; wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      BIND( ?lf AS ?legalForm ) BIND( ?cnt AS ?count ) OPTIONAL {
        ?legalForm rdfs:label ?labelFr FILTER ( LANG( ?labelFr ) = "fr" )
      }
      FILTER ( ?count > 499 )
    }
  } UNION {
    SELECT ( IRI( CONCAT ( "http://example.org/other" ) ) AS ?legalForm ) ( "AUTRES" @fr AS ?labelFr ) ( SUM( ?cnt ) AS ?count ) WHERE {
      {
        SELECT ?lf ( COUNT( DISTINCT ?company ) AS ?cnt ) WHERE {
          ?company wdt:P1616 ?siren ; wdt:P1454 ?lf ; wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      FILTER ( ?cnt <= 499 )
    }
  }
}
ORDER BY DESC ( ?count )

Using entities:
- France (wd:Q142), also known as FR, FRA, French Republic: is instance of sovereign state / is instance of country / is instance of republic / is instance of Republic / country in Western Europe / country in Western Europe / country with territory in Europe and several overseas regions and territories / republic in Western Europe

Using properties:
- legal form (wd:P1454 as wdt), also known as legal structure, structured as, P1454: is subproperty of instance of / legal form of an entity / legal form of an organisation
- SIREN number (wd:P1616 as wdt), also known as SIREN ID, SIREN identifier, P1616: identifier for an organization in the SIRENE register maintained by INSEE
- 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)

Execution result:
Got 25 rows and 3 columns, showing the first 5 and last 5 rows below:
| legalForm                                                                        | labelFr                                                                        | count            |
| -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ | ---------------- |
| limited liability company (with no further details) (wd:Q98889979)               | société à responsabilité limitée (sans autre indication) (lang:fr)             | 145510 (xsd:int) |
| wd:Q112176862                                                                    | société par actions simplifiée (lang:fr)                                       | 132442 (xsd:int) |
| commune et commune nouvelle (wd:Q112226256)                                      | commune et commune nouvelle (lang:fr)                                          | 36653 (xsd:int)  |
| municipal social welfare centre (wd:Q2944984)                                    | centre communal d'action sociale (lang:fr)                                     | 17152 (xsd:int)  |
| Foreign company not registered with the RCS (wd:Q112176662)                      | société étrangère non immatriculée au RCS (lang:fr)                            | 16572 (xsd:int)  |
| ...                                                                              | ...                                                                            | ...              |
| SA à directoire (s.a.i.) (wd:Q110567707)                                         | SA à directoire (s.a.i.) (lang:fr)                                             | 776 (xsd:int)    |
| service déconcentré de l'état à compétence (inter) départementale (wd:Q87713520) | service déconcentré de l'état à compétence (inter) départementale (lang:fr)    | 744 (xsd:int)    |
| wd:Q112176968                                                                    | commune associée et commune déléguée (lang:fr)                                 | 639 (xsd:int)    |
| groupement d'intérêt économique (wd:Q3118017)                                    | groupement d'intérêt économique (lang:fr)                                      | 569 (xsd:int)    |
| wd:Q112176670                                                                    | régie d'une collectivité locale à caractère industriel ou commercial (lang:fr) | 513 (xsd:int)    |

[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 is the number of legal units for each level 3 legal category in France, with the category name in French, where the count of legal units is greater than 499? Additionally, provide a summary line labeled "OTHER" that sums up the number of legal units for all other categories with counts of 499 or less.

[Assistant]
I'll search Wikidata for properties and items related to "legal unit", "legal category", "level 3", and France to find the correct properties and items to use. I'll start by searching for entities matching "legal unit" and then properties for legal category.

Question: legal unit France "legal unit"

Top 10 entity alternatives:
1. Monetary Gold Removed from Rome in 1943 (wd:Q6898995, matched via Italy v France, United Kingdom and United States), also known as Italy v France, United Kingdom and United States: case decided by the International Court of Justice / is instance of legal case
2. law of France (wd:Q1195493, matched via legal regime in France), also known as body of law in France, body of law of France, French body of law, French law, French legal regime, etc.: body of law in France / body of law in France / is subclass of law / is subclass of Law
3. Brigade anti-criminalité (wd:Q2925231, matched via Anti Crime Unit (France)), also known as Anti Crime Unit (France): French anti-crime unit
4. legal history of France (wd:Q3137849): is instance of legal history
5. legal unit of measure (wd:Q22282168): is subclass of unit of measurement
6. Legal assistance in France (wd:Q2827799)
7. legal advocate in France (wd:Q791243): is instance of legal profession / is subclass of advocate / is subclass of Advocate / profession
8. Legal separation in France (wd:Q16678578): is instance of legal separation
9. legal deposit in France (wd:Q3044959): is subclass of legal deposit / is subclass of Legal deposit
10. legal doctrine in France (wd:Q2371351): is subclass of legal doctrine / is subclass of Legal doctrine

[Assistant]
I'll search for entities with French label "unité légale" and also for items about INSEE legal unit categories (e.g., "categorie juridique") to find the correct item/property to use. I'll start with "unité légale".

Question: unité légale

Top 10 entity alternatives:
1. Saint-Nicolas-lès-Cîteaux (wd:Q16626, matched via Unité), also known as Unité: is instance of commune of France / commune in Côte-d'Or, France
2. Relevant (wd:Q966793, matched via Unité), also known as Saint-Christophe-de-Relevant (rattaché à Relevant), Saint-Cyr-de-Relevant (rattaché à Relevant), Unité: is instance of commune of France / commune in Ain, France
3. Sainte-Marie-au-Bosc (wd:Q766615, matched via Unité), also known as Unité: commune in Seine-Maritime, France / is instance of commune of France
4. Lalœuf (wd:Q1099812, matched via Unité), also known as Unité: commune in Meurthe-et-Moselle, France / is instance of commune of France
5. Nocé (wd:Q1389349, matched via Unité), also known as Saint-Quentin-le-Petit (réunie à Nocé), Unité: is instance of delegated commune / is instance of commune of France / former commune in Orne, France
6. Unité d'habitation (wd:Q1412364), also known as Unité d'Habitation Building Style: modernist residential housing design principle developed by ... with the collaboration of painter-architect Nadir Afonso
7. Harry Potter: Wizards Unite (wd:Q50296394, matched via Wizards Unite), also known as Harry Potter Wizards Unite, Wizards Unite: free-to-play location-based augmented reality mobile game developed by Niantic and WB Games San Francisco / is instance of video game
8. Pokémon Unite (wd:Q96622951): multiplayer online battle arena video game / is instance of esports discipline / is instance of video game / 2021 video game / 2021 video game
9. Nicktoons Unite! (wd:Q2907894), also known as SpongeBob SquarePants and Friends: Unite!: is instance of video game / 2005 video game / 2005 video game / 2005 video game
10. University of Teramo (wd:Q2303527, matched via UniTE), also known as UniTE, Università degli Studi di Teramo: is instance of public university / Italian university

[Assistant]
I'll search for properties named like "legal form", "legal category", "categorie juridique", or related to INSEE legal units.

Question: legal form

Top 10 property alternatives:
1. legal form (wd:P1454 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn), also known as legal structure, structured as, P1454: is subproperty of instance of / legal form of an organisation / legal form of an entity
2. official name (wd:P1448 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via legal name), also known as be named, complete title, full title, legal name, long name, etc.: official name of the subject in its official language(s) / official name of the subject in its official language(s) / official name of the subject in its official language(s) / is subproperty of name
3. writing system (wd:P282 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via written form), also known as script, writing script, written form, P282: alphabet, character set or other system of writing used by a language, word, or text, supported by a typeface / the writing system used by language
4. main regulatory text (wd:P92 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via legal basis), also known as authorizing legislation, by-laws, bylaws, governing document, governing text, etc.: text setting the main rules by which the subject is regulated / text setting the main rules by which the subject is regulated / text setting the main rules by which the subject is regulated
5. ELF code (wd:P10421 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via entity legal form ID), also known as entity legal form ID, GLEI ELF, GLEIF ELF code, P10421: code for entity legal form (ELF), assigned by the Global Legal Entity Identifier Foundation (GLEIF) per ISO 20275
6. applies to part (wd:P518 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via in form), also known as applied to, applies to aspect, applies to form, applies to phase, apply to, etc.: part, aspect, or form of the item to which the claim applies / part of the item for which the claim is valid / part of the item for which the claim is valid
7. subclass of (wd:P279 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via form of), 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
8. bill number (wd:P10703 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via legal number), also known as legal number, P10703: number assigned to a bill to be submitted to the parliament of the state or local government
9. laws applied (wd:P3014 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via legal base), also known as applied law, law applied, legal base, P3014: the constitutional and statutory provisions that were the primary basis for a decision or law / the constitutional and statutory provisions that were the primary basis for the decision
10. legal status (medicine) (wd:P3493 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn), also known as P3493: legal status for pharmaceutical drugs, e.g. general sales list for paracetamol in the UK

[Assistant]
I'll search for entities with French labels like "catégorie juridique" or "catégorie juridique niveau 3" to find the classification items used for legal categories in France.

Question: cate9gorie juridique niveau 3

Top 10 entity alternatives:
1. March (wd:Q110, matched via 3. month), also known as 3. month, Mar: third month in the Julian and Gregorian calendars / third month in the Julian and Gregorian calendars / third month in the Julian and Gregorian calendars / is subclass of month of the Gregorian calendar / is instance of calendar month
2. January 3 (wd:Q2156), also known as 3 January, 3rd of January, Jan 3, January 3rd: is instance of point in time with respect to recurrent timeframe / is subclass of 3rd / day of the year / date
3. March 3 (wd:Q2391), also known as 3 March, 3rd of March, Mar 3, March 3rd: is instance of point in time with respect to recurrent timeframe / is subclass of 3rd / day of the year
4. February 3 (wd:Q2315), also known as 3 February, 3rd of February, Feb 3, February 3rd: is instance of point in time with respect to recurrent timeframe / is subclass of 3rd / day of the year / date
5. April 3 (wd:Q2509), also known as 3 April, 3rd of April, Apr 3, April 3rd: is instance of point in time with respect to recurrent timeframe / is subclass of 3rd / day of the year
6. November 3 (wd:Q2995), also known as 3 November, 3rd of November, Nov 3, November 3rd: is instance of point in time with respect to recurrent timeframe / is subclass of 3rd / day of the year
7. October 3 (wd:Q2931), also known as 3 October, 3rd of October, Oct 3, October 3rd: is instance of point in time with respect to recurrent timeframe / is subclass of 3rd / date
8. June 3 (wd:Q2623), also known as 3 June, 3rd of June, Jun 3, June 3rd: is instance of point in time with respect to recurrent timeframe / is subclass of 3rd / day of the year
9. September 3 (wd:Q2860, matched via 3 September), also known as 3rd of September, 3 September, Sep 3, September 3rd: is instance of point in time with respect to recurrent timeframe / is subclass of 3rd / date

[Assistant]
I'll look up how P1454 (legal form) is used and search for objects of that property matching "France" or French labels.

Question: France

Top 10 entity alternatives:
1. société anonyme (wd:Q18195767, matched via SA (France)), also known as S.A., SA (France), Société anonyme, Société anonyme (France): is instance of type of legal entity in France / is subclass of commercial company in France / is instance of type of business entity / is subclass of joint-stock company / legal form for companies in France / type of company in French law / is instance of legal form / is subclass of S.A. / is subclass of S.A
2. European economic interest group (wd:Q112176872, matched via EEIG (France)), also known as EEIG (France): is subclass of European economic interest grouping / is instance of type of legal entity in France / legal category of EEIG in France / is instance of legal form
3. department of France (wd:Q6465), also known as departement, département, department, departments of France, French department: is subclass of second-level administrative country subdivision / is subclass of third-level administrative country subdivision / is instance of type of French administrative division / is subclass of NUTS 3 statistical territorial entity / is subclass of second-level administrative division / is subclass of third-level administrative division / is subclass of territorial collectivity of France / administrative subdivision in France / is subclass of electoral unit / is subclass of constituency / is subclass of department / is subclass of riding
4. prefecture (wd:Q179831, matched via prefecture in France), also known as French prefecture, French préfecture, French prefectures, French préfectures, préfecture, etc.: is subclass of public administration of France / is instance of type of legal entity in France / governmental subdivision in France / is subclass of prefecture / is subclass of Prefecture
5. Région de France (wd:Q17561724): is subclass of territorial collectivity of France / legal category of French territorial authority / is instance of type of legal entity in France / is instance of legal form
6. undeclared association (wd:Q111191469, matched via unincorporated association (France)), also known as association non déclarée, unincorporated association (France): is subclass of association under the French law of 1901 and similar / is subclass of juridical person under French law / is instance of type of legal entity in France / type of legal entity in France / is instance of legal form
7. declared association (wd:Q111166550, matched via incorporated association (France)), also known as association déclarée, incorporated association (France): is subclass of association under the French law of 1901 and similar / is instance of type of legal entity in France / type of legal entity in France / is instance of legal form / is subclass of club
8. agglomeration community (wd:Q159321, matched via agglomeration community of France), also known as agglomeration community of France, communauté d'agglomération: is subclass of public institution of intermunicipal cooperation with own taxation / France intercommunal subdivision combining a commune and its suburbs / is subclass of public establishment of an administrative nature / is instance of type of legal entity in France / is instance of legal form
9. commune community (wd:Q423785, matched via commune community in France), also known as communauté de communes, communautés de communes, commune community in France, commune community of France, communites of communes, etc.: type of French public institution for intermunicipal cooperation, bringing together neighboring municipalities / is subclass of public institution of intermunicipal cooperation with own taxation / is subclass of public establishment of an administrative nature / is instance of type of legal entity in France / is instance of legal form
10. urban community (wd:Q423790, matched via urban community of France), also known as urban community of France: is subclass of public institution of intermunicipal cooperation with own taxation / France intercommunal subdivision integrating a city and its suburbs / is subclass of public establishment of an administrative nature / is instance of type of legal entity in France / is instance of legal form

No other items found

No literal items found

[Assistant]
I'll search for properties related to "level 3" and for items labelled "niveau 3" or "level 3" to find INSEE or similar classification properties. I will look for properties with "level 3", "level 3 legal", "niveau 3", "categorie niveau 3".

Question: niveau 3

Top 10 property alternatives:
1. triples hit (wd:P9225 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via 3B), also known as 3B, allowed triples, career total triples, career triples, career triples hit, etc.: number of triples hit by a baseball player in a career or game(s)
2. next lower rank (wd:P3729 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via lower level), also known as lower level, lower rank, next (lower), next lower level, P3729: lower rank or level in a ranked hierarchy like sport league, ... For sports leagues/taxa, use specific properties instead. / is subproperty of follows
3. position held (wd:P39 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via P39), also known as function, held position, holds position, job, office held, etc.: subject currently or formerly holds the object position or public office / subject currently or formerly holds the object position or public office / subject currently or formerly holds the object position or public office / subject currently or formerly holds the object position or public office
4. next level in hierarchy (wd:P10229 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn), also known as P10229: qualifier: indicates the value at the next hierarchy level ... this item, when more than one is possible at the next level
5. capital (wd:P36 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via P36), 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
6. next higher rank (wd:P3730 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via higher level), also known as higher level, higher rank, next (higher), next higher level, P3730: higher rank or level in a ranked hierarchy like sport league, ... For sports leagues/taxa, use specific properties instead. / is subproperty of followed by
7. official language (wd:P37 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via P37), also known as language official, language spoken, speaking, spoken in, P37: language designated as official by this item / language designated as official by this item / language designated as official by this item / language designated as official by this item / is subproperty of language used
8. currency (wd:P38 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via P38), also known as base currency, used money, P38: is subproperty of uses / currency used by item / currency used by item / currency used by item
9. edition number (wd:P393 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via P393), also known as number of event, software version number, version number, P393: number of this edition (first, second, ... as 1, 2, ...) of a book or event / number of an edition (first, second, ... as 1, 2, ...) or event / is subproperty of series ordinal
10. continent (wd:P30 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via P30), also known as P30: is subproperty of located in/on physical feature / is subproperty of located on terrain feature / continent of which the subject is a part / continent of which the subject is a part / continent of which the subject is a part

[Assistant]
I'll search for items and properties containing "cat\u00e9gorie juridique" and "cat\u00e9gorie juridique niveau 3" to locate the INSEE classification in Wikidata. I'll explain my reasoning and then run constrained searches.

Question: cate9gorie juridique

Top 10 entity alternatives:
1. Franco-German Legal Centre (wd:Q118884, matched via Centre juridique franco-allemand), also known as Centre juridique franco-allemand, CJFA: is instance of public university / French law school in Germany
2. Librairie Dalloz (wd:Q109355340, matched via Librairie juridique Dalloz), also known as Librairie juridique Dalloz: is instance of bookstore / is instance of bookshop / bookshop in Paris / bookshop in Paris
3. La formation juridique (wd:Q130309545): journal article from 'Revue de droit. Université de Sherbrooke' published in 1987 / is instance of scholarly article / is instance of academic article
4. Classification juridique romande (wd:Q130325066): rdf datatype; published by Swiss Institute of Comparative Law in Lausanne / is instance of RDF datatype IRI
5. Textes juridiques (wd:Q101457352): scientific article published on 31 October 2020 / scientific article published on 31 October 2020 / scientific article published on 31 October 2020 / is instance of scholarly article / is instance of academic article
6. La terminologie juridique (wd:Q102211243): scientific article published on 24 October 2020 / is instance of scholarly article / is instance of academic article
7. Le Quotidien juridique (wd:Q26710108), also known as Le Quotidien juridique (1992): is instance of periodical / French periodical
8. Revue juridique polynésienne (wd:Q15749877): is instance of scientific journal / journal
9. Revue juridique nîmoise (wd:Q64825574), also known as Rev. jurid. nîmoise: is instance of scientific journal / journal
10. Textes juridiques (wd:Q96163028): scientific article published on 23 May 2020 / scientific article published on 23 May 2020 / scientific article published on 23 May 2020 / is instance of scholarly article / is instance of academic article

[Assistant]
I will list triples for the item "société anonyme" (wd:Q18195767) to see what properties are used — maybe there are statements counting numbers of legal units in France. I'll inspect triples for that item.

list

wd:Q18195767

Got 949 rows and 3 columns, showing the first 10 rows below:
| subject                        | property                               | object                                  |
| ------------------------------ | -------------------------------------- | --------------------------------------- |
| société anonyme (wd:Q18195767) | instance of (wdt:P31)                  | type of business entity (wd:Q1269299)   |
| société anonyme (wd:Q18195767) | Google Knowledge Graph ID (wdtn:P2671) | <http://g.co/kg/g/11cfv1tv7>            |
| société anonyme (wd:Q18195767) | subclass of (wdt:P279)                 | joint-stock company (wd:Q134161)        |
| société anonyme (wd:Q18195767) | applies to jurisdiction (wdt:P1001)    | France (wd:Q142)                        |
| société anonyme (wd:Q18195767) | properties for this type (wdt:P1963)   | wd:P1616                                |
| société anonyme (wd:Q18195767) | ELF code (wdt:P10421)                  | QVPB                                    |
| société anonyme (wd:Q18195767) | wdt:P31279                             | legal form (wd:Q10541491)               |
| société anonyme (wd:Q18195767) | schema:description                     | companie pe acțiuni în Franța (lang:ro) |
| société anonyme (wd:Q18195767) | schema:name                            | sociedad anónima (lang:es)              |
| société anonyme (wd:Q18195767) | rdf:type                               | wikibase:Item                           |
| ...                            | ...                                    | ...                                     |

[Assistant]
I will search for an item describing the statistical concept "legal unit (INSEE)" using English and French terms ("legal unit", "unité légale", "unité juridique", "enterprise legal unit"). I explain: finding this concept will let us identify how counts are represented (e.g., via qualifiers or population-like statements) and which property links legal units to their legal category level 3.

Question: INSEE "legal unit" "unité légale"

Top 10 entity alternatives:
1. legal unit of measure (wd:Q22282168): is subclass of unit of measurement
2. United Nations Detention Unit (wd:Q2292661): Prison in the Netherlands / is instance of prison
3. United States Army Marksmanship Unit (wd:Q25221084): US Army training and recruiting unit / is instance of organisation / is instance of organization
4. United States legal system (wd:Q4445375), also known as court system of the United States, legal system of the United States: is instance of judiciary
5. United Arab Emirates Legal Process (wd:Q18356599)
6. United States Army sustainment unit (wd:Q21060161), also known as sustainment unit (United States Army): is instance of military unit branch-type class / is subclass of United States Army formation / is subclass of supply and maintenance unit / United States Army unit type designation
7. United States Army Medical Unit (wd:Q7889499): is instance of institute for medical research / is instance of United States Army formation / defunct US army medical research unit
8. United Nations Graphic Presentation Unit (wd:Q120373201): is instance of division
9. United States military band unit (wd:Q120143922), also known as American military band, military Band unit: military band unit of United States armed force / is subclass of United States military unit / is instance of military unit type class / is subclass of military band
10. United States navy band unit (wd:Q120146527), also known as band unit (united states navy), USN Band unit: is subclass of United States military band unit / is instance of military unit branch-type class / military band unit of United States navy

[Assistant]
I'll search for properties used on the "société anonyme" item that contain "number" or "count" to see how counts might be represented.

Question: number

Top 10 property alternatives:
1. applies to jurisdiction (wd:P1001 as p/wdt, matched via of), 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
2. instance of (wd:P31 as p/wdt, matched via type), also known as example of, has type, is a, is an, is of type, etc.: type to which this subject corresponds/belongs. Different ... and the volcano is a type (instance) of volcanic landform / that class of which this subject is a particular example and ... a subclass of mountain (and an instance of volcanic landform)
3. subclass of (wd:P279 as p/wdt, matched via type of), 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
4. Google Knowledge Graph ID (wd:P2671 as p/wdt/wdtn, matched via kgmid), also known as Google knowledge panel, Google Knowledge Panel ID, kgmid, MREID, P2671: identifier for Google Knowledge Graph API, starting with "/g/". For IDs starting with "/m/", use Freebase ID (P646) / identifier for Google Knowledge Graph API / identifier for Google Knowledge Graph API
5. properties for this type (wd:P1963 as p/wdt, matched via has properties), also known as has properties, has property, properties for this class, property for this class, property for this type, etc.: when this subject is used as object of “instance of”, the following properties normally apply / when this subject is used as object of “instance of”, the following properties normally apply
6. ELF code (wd:P10421 as p/wdt, matched via P10421), also known as entity legal form ID, GLEI ELF, GLEIF ELF code, P10421: code for entity legal form (ELF), assigned by the Global Legal Entity Identifier Foundation (GLEIF) per ISO 20275

No other items found

[Assistant]
I'll run an exploratory SPARQL query to find numeric literal properties used on items that apply to jurisdiction France (wd:Q142). This helps find how counts might be stored. I'll explain the query beforehand: it selects properties and a sample numeric literal for items with wdt:P1001 wd:Q142.

execute

SELECT DISTINCT ?p (SAMPLE(?o) AS ?sample) WHERE {
  ?item wdt:P1001 wd:Q142 .
  ?item ?p ?o .
  FILTER(isLiteral(?o))
  FILTER(datatype(?o) IN (xsd:decimal, xsd:integer, xsd:double, xsd:nonNegativeInteger, xsd:positiveInteger))
}
LIMIT 200

SPARQL execution failed:
Invalid SPARQL query: Variable ?p is selected but not aggregated. All non-aggregated variables must be part of the GROUP BY clause. Note: The GROUP BY in this query is implicit because an aggregate expression was used in the SELECT clause

[Assistant]
I'll rerun the query corrected to include GROUP BY for ?p.

SELECT DISTINCT ?p (SAMPLE(?o) AS ?sample) WHERE {
  ?item wdt:P1001 wd:Q142 .
  ?item ?p ?o .
  FILTER(isLiteral(?o))
  FILTER(datatype(?o) IN (xsd:decimal, xsd:integer, xsd:double, xsd:nonNegativeInteger, xsd:positiveInteger))
}
GROUP BY ?p
LIMIT 200

Got 27 rows and 2 columns, showing the first 5 and last 5 rows below:
| p                                        | sample                 |
| ---------------------------------------- | ---------------------- |
| quantity (wdt:P1114)                     | 20144 (xsd:decimal)    |
| employees (wdt:P1128)                    | 130906 (xsd:decimal)   |
| number of seats (wdt:P1342)              | 577 (xsd:decimal)      |
| number of seats in assembly (wdt:P1410)  | 0 (xsd:decimal)        |
| total valid votes (wdt:P1697)            | 18141416 (xsd:decimal) |
| ...                                      | ...                    |
| number of spoilt votes (wdt:P5044)       | 1114613 (xsd:decimal)  |
| number of blank votes (wdt:P5045)        | 1239928 (xsd:decimal)  |
| social media followers (wdt:P8687)       | 2864064 (xsd:decimal)  |
| number of taxpayers (wdt:P8876)          | 188 (xsd:decimal)      |
| Egapro gender equality index (wdt:P9279) | 92 (xsd:decimal)       |

[Assistant]
I'll run a SPARQL query to list items with applies to jurisdiction France (P1001 = Q142) and a numeric quantity (P1114). I'll request the French label of the item and the numeric quantity. This will help identify which items represent legal categories and whether P1114 holds counts of legal units.

SELECT ?item ?itemLabelFr ?count WHERE {
  ?item wdt:P1001 wd:Q142 .
  ?item wdt:P1114 ?count .
  OPTIONAL { ?item rdfs:label ?itemLabelFr . FILTER(LANG(?itemLabelFr) = "fr") }
}
LIMIT 200

Got 8 rows and 3 columns:
| item                                                     | itemLabelFr                                        | count                |
| -------------------------------------------------------- | -------------------------------------------------- | -------------------- |
| COVID-19 vaccination programme in France (wd:Q104864148) | vaccination contre le Covid-19 en France (lang:fr) | 422127 (xsd:decimal) |
| Regional nature park of France (wd:Q1818761)             | parc naturel régional de France (lang:fr)          | 58 (xsd:decimal)     |
| professeur des universités (wd:Q28004591)                | professeur des universités (lang:fr)               | 20144 (xsd:decimal)  |
| wd:Q3477483                                              | section de commune (lang:fr)                       | 27000 (xsd:decimal)  |
| syndicat d'agglomération nouvelle (wd:Q3508242)          | syndicat d’agglomération nouvelle (lang:fr)        | 0 (xsd:decimal)      |
| region of France (wd:Q36784)                             | région française (lang:fr)                         | 18 (xsd:decimal)     |
| commune of France (wd:Q484170)                           | commune française (lang:fr)                        | 34935 (xsd:decimal)  |
| department of France (wd:Q6465)                          | département français (lang:fr)                     | 101 (xsd:decimal)    |

[Assistant]
I'll search for entities with French label containing "niveau 3" to find taxonomy items. This is exploratory; I'll explain the query and then run it.

Question: niveau 3

Top 10 entity alternatives:
1. March (wd:Q110, matched via 3. month), also known as 3. month, Mar: third month in the Julian and Gregorian calendars / third month in the Julian and Gregorian calendars / third month in the Julian and Gregorian calendars / is subclass of month of the Gregorian calendar / is instance of calendar month
2. January 3 (wd:Q2156), also known as 3 January, 3rd of January, Jan 3, January 3rd: is instance of point in time with respect to recurrent timeframe / is subclass of 3rd / day of the year / date
3. March 3 (wd:Q2391), also known as 3 March, 3rd of March, Mar 3, March 3rd: is instance of point in time with respect to recurrent timeframe / is subclass of 3rd / day of the year
4. February 3 (wd:Q2315), also known as 3 February, 3rd of February, Feb 3, February 3rd: is instance of point in time with respect to recurrent timeframe / is subclass of 3rd / day of the year / date
5. April 3 (wd:Q2509), also known as 3 April, 3rd of April, Apr 3, April 3rd: is instance of point in time with respect to recurrent timeframe / is subclass of 3rd / day of the year
6. November 3 (wd:Q2995), also known as 3 November, 3rd of November, Nov 3, November 3rd: is instance of point in time with respect to recurrent timeframe / is subclass of 3rd / day of the year
7. October 3 (wd:Q2931), also known as 3 October, 3rd of October, Oct 3, October 3rd: is instance of point in time with respect to recurrent timeframe / is subclass of 3rd / date
8. June 3 (wd:Q2623), also known as 3 June, 3rd of June, Jun 3, June 3rd: is instance of point in time with respect to recurrent timeframe / is subclass of 3rd / day of the year
9. September 3 (wd:Q2860, matched via 3 September), also known as 3rd of September, 3 September, Sep 3, September 3rd: is instance of point in time with respect to recurrent timeframe / is subclass of 3rd / date

[Assistant]
I'll search for "catégorie juridique" as a phrase.

Question: cate9gorie juridique

Top 10 entity alternatives:
1. Franco-German Legal Centre (wd:Q118884, matched via Centre juridique franco-allemand), also known as Centre juridique franco-allemand, CJFA: is instance of public university / French law school in Germany
2. Librairie Dalloz (wd:Q109355340, matched via Librairie juridique Dalloz), also known as Librairie juridique Dalloz: is instance of bookstore / is instance of bookshop / bookshop in Paris / bookshop in Paris
3. La formation juridique (wd:Q130309545): journal article from 'Revue de droit. Université de Sherbrooke' published in 1987 / is instance of scholarly article / is instance of academic article
4. Classification juridique romande (wd:Q130325066): rdf datatype; published by Swiss Institute of Comparative Law in Lausanne / is instance of RDF datatype IRI
5. Textes juridiques (wd:Q101457352): scientific article published on 31 October 2020 / scientific article published on 31 October 2020 / scientific article published on 31 October 2020 / is instance of scholarly article / is instance of academic article
6. La terminologie juridique (wd:Q102211243): scientific article published on 24 October 2020 / is instance of scholarly article / is instance of academic article
7. Le Quotidien juridique (wd:Q26710108), also known as Le Quotidien juridique (1992): is instance of periodical / French periodical
8. Revue juridique polynésienne (wd:Q15749877): is instance of scientific journal / journal
9. Revue juridique nîmoise (wd:Q64825574), also known as Rev. jurid. nîmoise: is instance of scientific journal / journal
10. Textes juridiques (wd:Q96163028): scientific article published on 23 May 2020 / scientific article published on 23 May 2020 / scientific article published on 23 May 2020 / is instance of scholarly article / is instance of academic article

[Assistant]
Now I'll run a SPARQL query to list all legal form items (those with applies to jurisdiction France wdt:P1001 wd:Q142) that have a numeric quantity (wdt:P1114), returning French labels and counts. Then I'll filter by count>499. This tests whether P1114 is used to encode numbers of legal units per form. I will show the results to verify and then proceed to aggregate the 'OTHER' sum.

SELECT ?form ?formLabelFr ?count WHERE {
  ?form wdt:P1001 wd:Q142 .
  ?form rdfs:label ?formLabelFr . FILTER(LANG(?formLabelFr) = "fr")
  ?form wdt:P1114 ?count .
}
ORDER BY DESC(?count)
LIMIT 500

Got 8 rows and 3 columns:
| form                                                     | formLabelFr                                        | count                |
| -------------------------------------------------------- | -------------------------------------------------- | -------------------- |
| COVID-19 vaccination programme in France (wd:Q104864148) | vaccination contre le Covid-19 en France (lang:fr) | 422127 (xsd:decimal) |
| commune of France (wd:Q484170)                           | commune française (lang:fr)                        | 34935 (xsd:decimal)  |
| wd:Q3477483                                              | section de commune (lang:fr)                       | 27000 (xsd:decimal)  |
| professeur des universités (wd:Q28004591)                | professeur des universités (lang:fr)               | 20144 (xsd:decimal)  |
| department of France (wd:Q6465)                          | département français (lang:fr)                     | 101 (xsd:decimal)    |
| Regional nature park of France (wd:Q1818761)             | parc naturel régional de France (lang:fr)          | 58 (xsd:decimal)     |
| region of France (wd:Q36784)                             | région française (lang:fr)                         | 18 (xsd:decimal)     |
| syndicat d'agglomération nouvelle (wd:Q3508242)          | syndicat d’agglomération nouvelle (lang:fr)        | 0 (xsd:decimal)      |

[Assistant]
I'll search for properties like SIREN and SIRET (French company identifiers) to find items representing legal units (companies) in Wikidata. If many companies have SIREN or SIRET, we can treat items with those identifiers as legal units.

Question: SIREN

Top 10 property alternatives:
1. SIREN number (wd:P1616 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via SIREN identifier), also known as SIREN ID, SIREN identifier, P1616: identifier for an organization in the SIRENE register maintained by INSEE
2. child (wd:P40 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via son), also known as children, daughter, daughters, descendants, father of, etc.: subject has object as child. Do not use for stepchildren—use "relative" (P1038), qualified with "type of kinship" (P1039) / subject has the object in their family as their offspring son or daughter (independently of their age) / subject has object as biological, foster, and/or adoptive child / is subproperty of significant person / is subproperty of relative
3. produced sound (wd:P4733 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via sound made), also known as call, makes call, makes sound, sound, sound emitted, etc.: item for the sound generated by the subject, for instance the cry of an animal
4. NATO Stock Number (wd:P5581 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via NSN), also known as NSN, P5581: 13-digit numeric code identifying an object used by NATO member country armed forces
5. SMIRKS (wd:P12491 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn), also known as P12491: line notation that represents generic chemical reactions
6. RILM ID (wd:P9171 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via NYNYRILM), also known as NYNYRILM, P9171: identifier for an entity in the Répertoire International de Littérature Musicale through VIAF
7. sibling (wd:P3373 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via sib), also known as bro, brother, brother of, brother or sister, brothers, etc.: the subject and the object have at least one common parent ... etc.) and step-siblings (step-brothers, step-sisters, etc.) / the subject has the object as their sibling (brother, sister, ... etc.) and step-siblings (step-brothers, step-sisters, etc.) / is subproperty of relative
8. Reta Vortaro ID (wd:P8202 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via ReVo), also known as ReVo, P8202: entry of an Esperanto lexeme in Reta Vortaro
9. logo image (wd:P154 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via insignia), also known as insignia, logo, logomark, mark, marque, etc.: graphic mark or emblem commonly used by commercial enterprises, organisations and products / graphic mark or emblem commonly used by commercial enterprises, organisations and products / graphic mark or emblem commonly used by commercial enterprises, organizations and products / graphic mark or emblem commonly used by commercial enterprises, organizations and products / is subproperty of icon
10. ISIL (wd:P791 as pr/psn/wdtn/ps/prn/p/pq/pqv/wdt/prv/psv/pqn, matched via Isil), also known as International Standard Identifier for Libraries and Related Organizations, Isil, P791: International Standard Identifier for Libraries and Related Organizations / identifier for a library or related organization

[Assistant]
Plan: count Wikidata items that are legal units by presence of SIREN number (P1616), group by their legal form (P1454), restrict to those whose country (P17) is France (Q142). Produce rows with French labels for legal forms. Return rows where count>499. Also compute an "OTHER" synthetic row summing counts <=499. I'll run the SPARQL query built as described.

SELECT ?legalForm ?labelFr ?count WHERE {
  {
    SELECT ?legalForm ?labelFr ?count WHERE {
      {
        SELECT ?legalForm (COUNT(DISTINCT ?company) AS ?count) WHERE {
          ?company wdt:P1616 ?siren .
          ?company wdt:P1454 ?legalForm .
          ?company wdt:P17 wd:Q142 .
        }
        GROUP BY ?legalForm
      }
      OPTIONAL { ?legalForm rdfs:label ?labelFr FILTER(LANG(?labelFr) = "fr") }
      FILTER(?count > 499)
    }
  }
  UNION
  {
    SELECT (IRI(CONCAT("http://example.org/other")) AS ?legalForm) ("AUTRES"@fr AS ?labelFr) (SUM(?count) AS ?count) WHERE {
      {
        SELECT ?legalForm (COUNT(DISTINCT ?company) AS ?count) WHERE {
          ?company wdt:P1616 ?siren .
          ?company wdt:P1454 ?legalForm .
          ?company wdt:P17 wd:Q142 .
        }
        GROUP BY ?legalForm
      }
      FILTER(?count <= 499)
    }
  }
}
ORDER BY DESC(?count)

SPARQL execution failed:
Invalid SPARQL query: The target ?legalForm of an AS clause was already used in the query body.

[Assistant]
I'll run the corrected SPARQL that aggregates companies (items with SIREN P1616) by their legal form (P1454) for companies with country P17 France (Q142), selects legal forms with counts > 499, and adds an \"AUTRES\" (OTHER) synthetic row summing counts <= 499.

SELECT ?legalForm ?labelFr ?count WHERE {
  {
    SELECT ?legalForm ?labelFr ?count WHERE {
      {
        SELECT ?lf (COUNT(DISTINCT ?company) AS ?count) WHERE {
          ?company wdt:P1616 ?siren ;
                   wdt:P1454 ?lf ;
                   wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      BIND(?lf AS ?legalForm)
      OPTIONAL { ?legalForm rdfs:label ?labelFr FILTER(LANG(?labelFr) = "fr") }
      FILTER(?count > 499)
    }
  }
  UNION
  {
    SELECT (IRI(CONCAT("http://example.org/other")) AS ?legalForm) ("AUTRES"@fr AS ?labelFr) (SUM(?count) AS ?count) WHERE {
      {
        SELECT ?lf (COUNT(DISTINCT ?company) AS ?count) WHERE {
          ?company wdt:P1616 ?siren ;
                   wdt:P1454 ?lf ;
                   wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      FILTER(?count <= 499)
    }
  }
}
ORDER BY DESC(?count)

SPARQL execution failed:
Invalid SPARQL query: The target ?count of an AS clause was already used in the query body.

[Assistant]
I'll correct variable name collisions by using ?cnt in inner subselects and binding it to ?count in outer queries. Then I'll run the query.

SELECT ?legalForm ?labelFr ?count WHERE {
  {
    SELECT ?legalForm ?labelFr ?count WHERE {
      {
        SELECT ?lf (COUNT(DISTINCT ?company) AS ?cnt) WHERE {
          ?company wdt:P1616 ?siren ;
                   wdt:P1454 ?lf ;
                   wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      BIND(?lf AS ?legalForm)
      BIND(?cnt AS ?count)
      OPTIONAL { ?legalForm rdfs:label ?labelFr FILTER(LANG(?labelFr) = "fr") }
      FILTER(?count > 499)
    }
  }
  UNION
  {
    SELECT (IRI(CONCAT("http://example.org/other")) AS ?legalForm) ("AUTRES"@fr AS ?labelFr) (SUM(?cnt) AS ?count) WHERE {
      {
        SELECT ?lf (COUNT(DISTINCT ?company) AS ?cnt) WHERE {
          ?company wdt:P1616 ?siren ;
                   wdt:P1454 ?lf ;
                   wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      FILTER(?cnt <= 499)
    }
  }
}
ORDER BY DESC(?count)

Got 25 rows and 3 columns, showing the first 5 and last 5 rows below:
| legalForm                                                                        | labelFr                                                                        | count            |
| -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ | ---------------- |
| limited liability company (with no further details) (wd:Q98889979)               | société à responsabilité limitée (sans autre indication) (lang:fr)             | 145510 (xsd:int) |
| wd:Q112176862                                                                    | société par actions simplifiée (lang:fr)                                       | 132442 (xsd:int) |
| commune et commune nouvelle (wd:Q112226256)                                      | commune et commune nouvelle (lang:fr)                                          | 36653 (xsd:int)  |
| municipal social welfare centre (wd:Q2944984)                                    | centre communal d'action sociale (lang:fr)                                     | 17152 (xsd:int)  |
| Foreign company not registered with the RCS (wd:Q112176662)                      | société étrangère non immatriculée au RCS (lang:fr)                            | 16572 (xsd:int)  |
| ...                                                                              | ...                                                                            | ...              |
| SA à directoire (s.a.i.) (wd:Q110567707)                                         | SA à directoire (s.a.i.) (lang:fr)                                             | 776 (xsd:int)    |
| service déconcentré de l'état à compétence (inter) départementale (wd:Q87713520) | service déconcentré de l'état à compétence (inter) départementale (lang:fr)    | 744 (xsd:int)    |
| wd:Q112176968                                                                    | commune associée et commune déléguée (lang:fr)                                 | 639 (xsd:int)    |
| groupement d'intérêt économique (wd:Q3118017)                                    | groupement d'intérêt économique (lang:fr)                                      | 569 (xsd:int)    |
| wd:Q112176670                                                                    | régie d'une collectivité locale à caractère industriel ou commercial (lang:fr) | 513 (xsd:int)    |

[Assistant]
I'll re-run the same SPARQL query to fetch the full result rows so I can list them explicitly in the answer.

SELECT ?legalForm ?labelFr ?count WHERE {
  {
    SELECT ?legalForm ?labelFr ?count WHERE {
      {
        SELECT ?lf (COUNT(DISTINCT ?company) AS ?cnt) WHERE {
          ?company wdt:P1616 ?siren ;
                   wdt:P1454 ?lf ;
                   wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      BIND(?lf AS ?legalForm)
      BIND(?cnt AS ?count)
      OPTIONAL { ?legalForm rdfs:label ?labelFr FILTER(LANG(?labelFr) = "fr") }
      FILTER(?count > 499)
    }
  }
  UNION
  {
    SELECT (IRI(CONCAT("http://example.org/other")) AS ?legalForm) ("AUTRES"@fr AS ?labelFr) (SUM(?cnt) AS ?count) WHERE {
      {
        SELECT ?lf (COUNT(DISTINCT ?company) AS ?cnt) WHERE {
          ?company wdt:P1616 ?siren ;
                   wdt:P1454 ?lf ;
                   wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      FILTER(?cnt <= 499)
    }
  }
}
ORDER BY DESC(?count)

Got 25 rows and 3 columns, showing the first 5 and last 5 rows below:
| legalForm                                                                        | labelFr                                                                        | count            |
| -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ | ---------------- |
| limited liability company (with no further details) (wd:Q98889979)               | société à responsabilité limitée (sans autre indication) (lang:fr)             | 145510 (xsd:int) |
| wd:Q112176862                                                                    | société par actions simplifiée (lang:fr)                                       | 132442 (xsd:int) |
| commune et commune nouvelle (wd:Q112226256)                                      | commune et commune nouvelle (lang:fr)                                          | 36653 (xsd:int)  |
| municipal social welfare centre (wd:Q2944984)                                    | centre communal d'action sociale (lang:fr)                                     | 17152 (xsd:int)  |
| Foreign company not registered with the RCS (wd:Q112176662)                      | société étrangère non immatriculée au RCS (lang:fr)                            | 16572 (xsd:int)  |
| ...                                                                              | ...                                                                            | ...              |
| SA à directoire (s.a.i.) (wd:Q110567707)                                         | SA à directoire (s.a.i.) (lang:fr)                                             | 776 (xsd:int)    |
| service déconcentré de l'état à compétence (inter) départementale (wd:Q87713520) | service déconcentré de l'état à compétence (inter) départementale (lang:fr)    | 744 (xsd:int)    |
| wd:Q112176968                                                                    | commune associée et commune déléguée (lang:fr)                                 | 639 (xsd:int)    |
| groupement d'intérêt économique (wd:Q3118017)                                    | groupement d'intérêt économique (lang:fr)                                      | 569 (xsd:int)    |
| wd:Q112176670                                                                    | régie d'une collectivité locale à caractère industriel ou commercial (lang:fr) | 513 (xsd:int)    |

[Assistant]
I'll run a query that outputs a single concatenated column for each row (IRI | French label | count) to get the full list displayed.

SELECT (CONCAT(STR(?legalForm), " | ", COALESCE(?labelFr, ""), " | ", STR(?count)) AS ?row) WHERE {
  {
    SELECT ?legalForm ?labelFr ?count WHERE {
      {
        SELECT ?lf (COUNT(DISTINCT ?company) AS ?cnt) WHERE {
          ?company wdt:P1616 ?siren ;
                   wdt:P1454 ?lf ;
                   wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      BIND(?lf AS ?legalForm)
      BIND(?cnt AS ?count)
      OPTIONAL { ?legalForm rdfs:label ?labelFr FILTER(LANG(?labelFr) = "fr") }
      FILTER(?count > 499)
    }
  }
  UNION
  {
    SELECT (IRI(CONCAT("http://example.org/other")) AS ?legalForm) ("AUTRES"@fr AS ?labelFr) (SUM(?cnt) AS ?count) WHERE {
      {
        SELECT ?lf (COUNT(DISTINCT ?company) AS ?cnt) WHERE {
          ?company wdt:P1616 ?siren ;
                   wdt:P1454 ?lf ;
                   wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      FILTER(?cnt <= 499)
    }
  }
}
ORDER BY DESC(?count)

Got 25 rows and 1 column, showing the first 5 and last 5 rows below:
| row                                                                                |
| ---------------------------------------------------------------------------------------------------------------------- |
| http://www.wikidata.org/entity/Q98889979 | société à responsabilité limitée (sans autre indication) | 145510           |
| http://www.wikidata.org/entity/Q112176862 | société par actions simplifiée | 132442                                    |
| http://www.wikidata.org/entity/Q112226256 | commune et commune nouvelle | 36653                                        |
| http://www.wikidata.org/entity/Q2944984 | centre communal d'action sociale | 17152                                     |
| http://www.wikidata.org/entity/Q112176662 | société étrangère non immatriculée au RCS | 16572                          |
| ...                                                                                |
| http://www.wikidata.org/entity/Q110567707 | SA à directoire (s.a.i.) | 776                                             |
| http://www.wikidata.org/entity/Q87713520 | service déconcentré de l'état à compétence (inter) départementale | 744     |
| http://www.wikidata.org/entity/Q112176968 | commune associée et commune déléguée | 639                                 |
| http://www.wikidata.org/entity/Q3118017 | groupement d'intérêt économique | 569                                        |
| http://www.wikidata.org/entity/Q112176670 | régie d'une collectivité locale à caractère industriel ou commercial | 513 |

[Assistant]
I'll fetch the results in three batches (rows 1-10, 11-20, 21-30) to ensure the tool displays all rows fully. I'll run the first batch now.

SELECT (CONCAT(STR(?legalForm), " | ", COALESCE(?labelFr, ""), " | ", STR(?count)) AS ?row) WHERE {
  {
    SELECT ?legalForm ?labelFr ?count WHERE {
      {
        SELECT ?lf (COUNT(DISTINCT ?company) AS ?cnt) WHERE {
          ?company wdt:P1616 ?siren ;
                   wdt:P1454 ?lf ;
                   wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      BIND(?lf AS ?legalForm)
      BIND(?cnt AS ?count)
      OPTIONAL { ?legalForm rdfs:label ?labelFr FILTER(LANG(?labelFr) = "fr") }
      FILTER(?count > 499)
    }
  }
  UNION
  {
    SELECT (IRI(CONCAT("http://example.org/other")) AS ?legalForm) ("AUTRES"@fr AS ?labelFr) (SUM(?cnt) AS ?count) WHERE {
      {
        SELECT ?lf (COUNT(DISTINCT ?company) AS ?cnt) WHERE {
          ?company wdt:P1616 ?siren ;
                   wdt:P1454 ?lf ;
                   wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      FILTER(?cnt <= 499)
    }
  }
}
ORDER BY DESC(?count)
LIMIT 10
OFFSET 0

Got 10 rows and 1 column:
| row                                                                                |
| ------------------------------------------------------------------------------------------------------------ |
| http://www.wikidata.org/entity/Q98889979 | société à responsabilité limitée (sans autre indication) | 145510 |
| http://www.wikidata.org/entity/Q112176862 | société par actions simplifiée | 132442                          |
| http://www.wikidata.org/entity/Q112226256 | commune et commune nouvelle | 36653                              |
| http://www.wikidata.org/entity/Q2944984 | centre communal d'action sociale | 17152                           |
| http://www.wikidata.org/entity/Q112176662 | société étrangère non immatriculée au RCS | 16572                |
| http://www.wikidata.org/entity/Q976195 | syndicat intercommunal à vocation unique | 12445                    |
| http://example.org/other | AUTRES | 8176                                                                     |
| http://www.wikidata.org/entity/Q2933302 | caisse des écoles | 5061                                           |
| http://www.wikidata.org/entity/Q111166550 | association déclarée | 4900                                      |
| http://www.wikidata.org/entity/Q98897593 | société anonyme à conseil d'administration (s.a.i.) | 4739        |

[Assistant]
Now fetching rows 11–20.

SELECT (CONCAT(STR(?legalForm), " | ", COALESCE(?labelFr, ""), " | ", STR(?count)) AS ?row) WHERE {
  {
    SELECT ?legalForm ?labelFr ?count WHERE {
      {
        SELECT ?lf (COUNT(DISTINCT ?company) AS ?cnt) WHERE {
          ?company wdt:P1616 ?siren ;
                   wdt:P1454 ?lf ;
                   wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      BIND(?lf AS ?legalForm)
      BIND(?cnt AS ?count)
      OPTIONAL { ?legalForm rdfs:label ?labelFr FILTER(LANG(?labelFr) = "fr") }
      FILTER(?count > 499)
    }
  }
  UNION
  {
    SELECT (IRI(CONCAT("http://example.org/other")) AS ?legalForm) ("AUTRES"@fr AS ?labelFr) (SUM(?cnt) AS ?count) WHERE {
      {
        SELECT ?lf (COUNT(DISTINCT ?company) AS ?cnt) WHERE {
          ?company wdt:P1616 ?siren ;
                   wdt:P1454 ?lf ;
                   wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      FILTER(?cnt <= 499)
    }
  }
}
ORDER BY DESC(?count)
LIMIT 10
OFFSET 10

Got 10 rows and 1 column:
| row                                                                                |
| ------------------------------------------------------------------------------------------------------------------ |
| http://www.wikidata.org/entity/Q87715170 | syndicat mixte fermé | 3910                                             |
| http://www.wikidata.org/entity/Q423785 | communauté de communes | 3214                                             |
| http://www.wikidata.org/entity/Q112176657 | société commerciale étrangère immatriculée au RCS | 3178               |
| http://www.wikidata.org/entity/Q2375914 | syndicat intercommunal à vocation multiple | 2260                        |
| http://www.wikidata.org/entity/Q87715173 | syndicat mixte ouvert | 1420                                            |
| http://www.wikidata.org/entity/Q111302220 | établissement public local à caractère industriel ou commercial | 1281 |
| http://www.wikidata.org/entity/Q111191049 | société coopérative agricole | 1258                                    |
| http://www.wikidata.org/entity/Q98896016 | SA d'économie mixte à conseil d'administration | 1131                   |
| http://www.wikidata.org/entity/Q98887042 | société en nom collectif | 1080                                         |
| http://www.wikidata.org/entity/Q87715536 | établissement d'hospitalisation | 858                                   |

[Assistant]
Now fetching rows 21–30 (the last batch).

SELECT (CONCAT(STR(?legalForm), " | ", COALESCE(?labelFr, ""), " | ", STR(?count)) AS ?row) WHERE {
  {
    SELECT ?legalForm ?labelFr ?count WHERE {
      {
        SELECT ?lf (COUNT(DISTINCT ?company) AS ?cnt) WHERE {
          ?company wdt:P1616 ?siren ;
                   wdt:P1454 ?lf ;
                   wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      BIND(?lf AS ?legalForm)
      BIND(?cnt AS ?count)
      OPTIONAL { ?legalForm rdfs:label ?labelFr FILTER(LANG(?labelFr) = "fr") }
      FILTER(?count > 499)
    }
  }
  UNION
  {
    SELECT (IRI(CONCAT("http://example.org/other")) AS ?legalForm) ("AUTRES"@fr AS ?labelFr) (SUM(?cnt) AS ?count) WHERE {
      {
        SELECT ?lf (COUNT(DISTINCT ?company) AS ?cnt) WHERE {
          ?company wdt:P1616 ?siren ;
                   wdt:P1454 ?lf ;
                   wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      FILTER(?cnt <= 499)
    }
  }
}
ORDER BY DESC(?count)
LIMIT 10
OFFSET 20

Got 5 rows and 1 column:
| row                                                                                |
| ---------------------------------------------------------------------------------------------------------------------- |
| http://www.wikidata.org/entity/Q110567707 | SA à directoire (s.a.i.) | 776                                             |
| http://www.wikidata.org/entity/Q87713520 | service déconcentré de l'état à compétence (inter) départementale | 744     |
| http://www.wikidata.org/entity/Q112176968 | commune associée et commune déléguée | 639                                 |
| http://www.wikidata.org/entity/Q3118017 | groupement d'intérêt économique | 569                                        |
| http://www.wikidata.org/entity/Q112176670 | régie d'une collectivité locale à caractère industriel ou commercial | 513 |

[Assistant]
answer

SELECT ?legalForm ?labelFr ?count WHERE {
  {
    SELECT ?legalForm ?labelFr ?count WHERE {
      {
        SELECT ?lf (COUNT(DISTINCT ?company) AS ?cnt) WHERE {
          ?company wdt:P1616 ?siren ;
                   wdt:P1454 ?lf ;
                   wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      BIND(?lf AS ?legalForm)
      BIND(?cnt AS ?count)
      OPTIONAL { ?legalForm rdfs:label ?labelFr FILTER(LANG(?labelFr) = "fr") }
      FILTER(?count > 499)
    }
  }
  UNION
  {
    SELECT (IRI(CONCAT("http://example.org/other")) AS ?legalForm) ("AUTRES"@fr AS ?labelFr) (SUM(?cnt) AS ?count) WHERE {
      {
        SELECT ?lf (COUNT(DISTINCT ?company) AS ?cnt) WHERE {
          ?company wdt:P1616 ?siren ;
                   wdt:P1454 ?lf ;
                   wdt:P17 wd:Q142 .
        }
        GROUP BY ?lf
      }
      FILTER(?cnt <= 499)
    }
  }
}
ORDER BY DESC(?count)

Answer:
Assumptions and approach:
- I interpreted “legal units” as Wikidata items that have a French SIREN identifier (property P1616). These are the best proxy in Wikidata for INSEE legal units.
- I interpreted “level 3 legal category” as the company/legal form value given by property P1454 (legal form). Using that property groups legal units by their legal category.
- The query counts distinct Wikidata items with a SIREN (P1616) in France (country P17 = Q142) grouped by their legal form (P1454). It returns legal forms with count > 499 and a synthetic "AUTRES" (OTHER) row summing all categories with counts ≤ 499.

SPARQL used (already executed against Wikidata):

[the query is included above]

Results (legalForm IRI | French label | count) — categories with counts > 499 plus the AUTRES summary:
1) http://www.wikidata.org/entity/Q98889979 | société à responsabilité limitée (sans autre indication) | 145510
2) http://www.wikidata.org/entity/Q112176862 | société par actions simplifiée | 132442
3) http://www.wikidata.org/entity/Q112226256 | commune et commune nouvelle | 36653
4) http://www.wikidata.org/entity/Q2944984 | centre communal d'action sociale | 17152
5) http://www.wikidata.org/entity/Q112176662 | société étrangère non immatriculée au RCS | 16572
6) http://www.wikidata.org/entity/Q976195 | syndicat intercommunal à vocation unique | 12445
7) http://example.org/other | AUTRES | 8176
8) http://www.wikidata.org/entity/Q2933302 | caisse des écoles | 5061
9) http://www.wikidata.org/entity/Q111166550 | association déclarée | 4900
10) http://www.wikidata.org/entity/Q98897593 | société anonyme à conseil d'administration (s.a.i.) | 4739
11) http://www.wikidata.org/entity/Q87715170 | syndicat mixte fermé | 3910
12) http://www.wikidata.org/entity/Q423785 | communauté de communes | 3214
13) http://www.wikidata.org/entity/Q112176657 | société commerciale étrangère immatriculée au RCS | 3178
14) http://www.wikidata.org/entity/Q2375914 | syndicat intercommunal à vocation multiple | 2260
15) http://www.wikidata.org/entity/Q87715173 | syndicat mixte ouvert | 1420
16) http://www.wikidata.org/entity/Q111302220 | établissement public local à caractère industriel ou commercial | 1281
17) http://www.wikidata.org/entity/Q111191049 | société coopérative agricole | 1258
18) http://www.wikidata.org/entity/Q98896016 | SA d'économie mixte à conseil d'administration | 1131
19) http://www.wikidata.org/entity/Q98887042 | société en nom collectif | 1080
20) http://www.wikidata.org/entity/Q87715536 | établissement d'hospitalisation | 858
21) http://www.wikidata.org/entity/Q110567707 | SA à directoire (s.a.i.) | 776
22) http://www.wikidata.org/entity/Q87713520 | service déconcentré de l'état à compétence (inter) départementale | 744
23) http://www.wikidata.org/entity/Q112176968 | commune associée et commune déléguée | 639
24) http://www.wikidata.org/entity/Q3118017 | groupement d'intérêt économique | 569
25) http://www.wikidata.org/entity/Q112176670 | régie d'une collectivité locale à caractère industriel ou commercial | 513

Notes and caveats:
- This reflects counts of Wikidata items (entities) that have SIREN identifiers and a legal form. It is not authoritative INSEE statistics — Wikidata coverage is incomplete and biased by which entities editors have added.
- The synthetic AUTRES row uses a generated IRI (http://example.org/other) and label "AUTRES"@fr to represent the aggregated categories with counts ≤ 499.

If you want, I can:
- Return only the legal forms (IRIs) and counts (no labels), or include English labels as well.
- Change the definition of "legal unit" (e.g., include items with SIRET instead of/in addition to SIREN), or use a different criterion for "France" (e.g., items with applies-to-jurisdiction P1001 = Q142).
- Export the full table as CSV.