Employers: discover CodinGame for tech hiring
CodinGame - Home
ACTIVITIES
PRACTICE
COMPETE
COOPERATE
LEARN
EVENTS
COMMUNITY
CONTRIBUTIONS
LIVE STREAMS
DISCORD
FORUMS
BLOG
Log In
Sign Up
An introduction to RDF querying in SPARQL
Zwifi
15.6K views
01
Welcome
02
Initial queries
03
Filters
04
Optionality
05
Negation
06
Alternatives
07
Projection
08
Grouping
09
Modifiers
8/9
Grouping
Previous:
Projection
Next:
Modifiers
Grouping results
Aggregation
Aggregation and projection
count_roles_as.sparql
matrix.ttl
1
2
3
4
5
6
7
8
9
PREFIX yaco: <https://www.irit.fr/recherches/MELOD
I/ontologies/cinema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-synt
ax-ns#>
SELECT ?name (COUNT(?role) AS ?nb_roles)
WHERE {
?actor rdf:type yaco:Actor;
rdfs:label ?name;
yaco:playsRole ?role.
} GROUP BY ?actor
1
@prefix yaco: <https://www.irit.fr/recherches/MELO
DI/ontologies/cinema#> .
Run
Who is he oldest actor?
min_actor.sparql
matrix.ttl
1
2
3
4
5
6
7
8
9
PREFIX yaco: <https://www.irit.fr/recherches/MELOD
I/ontologies/cinema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-synt
ax-ns#>
SELECT ?name (MIN(?year) as ?minYear)
WHERE {
?actor rdf:type yaco:Actor;
rdfs:label ?name;
yaco:birthYear ?year.
}
1
@prefix yaco: <https://www.irit.fr/recherches/MELO
DI/ontologies/cinema#> .
Run
Group filtering
Who are the actors who played in at least two movies?
having_roles.sparql
matrix.ttl
1
2
3
4
5
6
7
8
9
10
PREFIX yaco: <https://www.irit.fr/recherches/MELOD
I/ontologies/cinema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-synt
ax-ns#>
SELECT ?name
WHERE {
?actor rdf:type yaco:Actor;
rdfs:label ?name;
yaco:playsRole ?role.
} GROUP BY ?actor
HAVING (COUNT(?role) > 2)
1
@prefix yaco: <https://www.irit.fr/recherches/MELO
DI/ontologies/cinema#> .
Run
5
0
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
Suggested playgrounds
Common patterns with Solid
By
Zwifi
4,197
2
0
Learning algorithmics with Ada
By
Zwifi
15K
3
0
Beginner Python Concepts
By
a-Rye
12.5K
99
0
JavaScript Array Methods
By
SofienDerbel
2,718
72
0
CodinGame - Home
ABOUT US
CAREERS
PRIVACY
FAQ
CodinGame - Work
The #1 tech hiring platform
SCREENING
RETAIN
ABOUT US
CAREERS
PRIVACY
FAQ
Facebook
YouTube
Twitter
LinkedIn
FR
EN
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants
Keyboard Shortcuts:
?
Show / hide this help menu
×