User:HTriedman (WMF)/spinachbot test

@SpinachBot Give me a list of the last 7 French prime ministers. HTriedman (WMF) (talk) 17:28, 8 July 2024 (UTC)

Here is the SPARQL query and the result for the last seven French prime ministers:

SPARQL Query:

edit
SELECT ?pm ?pmLabel ?start_date ?end_date WHERE {
  ?pm p:P39 ?statement.
  ?statement ps:P39 wd:Q1587677;
    pq:P580 ?start_date.
  OPTIONAL { ?statement pq:P582 ?end_date. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC (?start_date)
LIMIT 7

Result:

edit
pm pmLabel start_date end_date
Q30339350 Gabriel Attal 2024-01-09T00:00:00Z -
Q20020731 Élisabeth Borne 2022-05-16T00:00:00Z 2024-01-09T00:00:00Z
Q3171170 Jean Castex 2020-07-03T00:00:00Z 2022-05-16T00:00:00Z
Q3579995 Édouard Philippe 2017-05-15T00:00:00Z 2020-07-03T00:00:00Z
Q560890 Bernard Cazeneuve 2016-12-06T00:00:00Z 2017-05-10T00:00:00Z
Q10287 Manuel Valls 2014-03-31T00:00:00Z 2016-12-06T00:00:00Z
Q7711 Jean-Marc Ayrault 2012-05-15T00:00:00Z 2014-03-31T00:00:00Z

This list includes the last seven individuals who held the position of Prime Minister of France, ordered by the start date of their term.

Here's my trace of reasonings and actions for this request so you can see how I came to this conclusion. SpinachBot (talk) 21:33, 8 July 2024 (UTC)

@User:SpinachBot This is pretty cool, but could you actually include the party of each prime minister as well as their name and time in office? HTriedman (WMF) (talk) 21:37, 8 July 2024 (UTC)

Here is the SPARQL query and the result for the last seven French prime ministers, including their political party:

SPARQL Query:

edit
SELECT ?pm ?pmLabel ?start_date ?end_date (SAMPLE(?party) AS ?party) (SAMPLE(?partyLabel) AS ?partyLabel) WHERE {
  ?pm p:P39 ?statement.
  ?statement ps:P39 wd:Q1587677;
    pq:P580 ?start_date.
  OPTIONAL { ?statement pq:P582 ?end_date. }
  OPTIONAL { ?pm wdt:P102 ?party. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?pm ?pmLabel ?start_date ?end_date
ORDER BY DESC (?start_date)
LIMIT 7

Result:

edit
pm pmLabel start_date end_date party partyLabel
Q30339350 Gabriel Attal 2024-01-09T00:00:00Z - Q170972 Socialist Party
Q20020731 Élisabeth Borne 2022-05-16T00:00:00Z 2024-01-09T00:00:00Z Q23731823 Renaissance
Q3171170 Jean Castex 2020-07-03T00:00:00Z 2022-05-16T00:00:00Z Q23731823 Renaissance
Q3579995 Édouard Philippe 2017-05-15T00:00:00Z 2020-07-03T00:00:00Z Q170972 Socialist Party
Q560890 Bernard Cazeneuve 2016-12-06T00:00:00Z 2017-05-10T00:00:00Z Q170972 Socialist Party
Q10287 Manuel Valls 2014-03-31T00:00:00Z 2016-12-06T00:00:00Z Q170972 Socialist Party
Q7711 Jean-Marc Ayrault 2012-05-15T00:00:00Z 2014-03-31T00:00:00Z Q170972 Socialist Party

This list includes the last seven individuals who held the position of Prime Minister of France, ordered by the start date of their term, along with their political party.

Here's my trace of reasonings and actions for this request so you can see how I came to this conclusion. SpinachBot (talk) 21:39, 8 July 2024 (UTC)