On Apr 7, 2025, at 9:39 AM, Simeon Warner <[log in to unmask]> wrote:
> Have you tried removing "LIMIT 1"? Of course, the data has to be there too.
>
> --
> Simeon
Loosing LIMIT 1? Well, duh. That's a good idea, and over on the LD4Libraries Slack channel, the following SPARQL query was suggested, where DISTINCT was also employed:
SELECT DISTINCT ?label ?description ?genderLabel ?occupationLabel
WHERE {
wd:Q91 rdfs:label ?label .
wd:Q91 schema:description ?description .
wd:Q91 wdt:P21 ?gender .
wd:Q91 wdt:P106 ?occupation .
FILTER (langMatches(lang(?label), "en-us"))
FILTER (langMatches(lang(?description), "en-us"))
SERVICE wikibase:label {bd:serviceParam wikibase:language 'en-us' .}
}
This returns seven records, one for each occupation.
But I'm never satisfied. What I'd like to see is a single record with all of the occupations concatonated together. GROUP_CONCAT begins to do this work, like this:
SELECT (group_concat(?occupation) as ?occupations)
WHERE {
wd:Q91 wdt:P106 ?occupation .
}
But as soon as I augment the SELECT statement with additional values, I get syntax errors:
SELECT ?label (group_concat(?occupation) as ?occupations)
WHERE {
wd:Q91 rdfs:label ?label .
FILTER (langMatches(lang(?label), "en-us"))
wd:Q91 wdt:P106 ?occupation .
}
What do y'all suggest?
--
Eric Morgan
University of Notre Dame
|