--1
select * where {
  ?name ?type ?value
}

--2
select ?name ?value where {
  ?name rdf:type ?value
}

--3
@prefix booksschema: <http://www.example.org/sprql-td/vocabs/> .
select ?name ?value where {
  ?name rdf:type booksschema:Book .
  ?name booksschema:hasGenre ?value .
}


--4
@prefix booksschema: <http://www.example.org/sprql-td/vocabs/> .
@prefix dcterms: <http://purl.org/dc/terms/>.

select ?name ?gender ?value where {
  ?name rdf:type booksschema:Book .
  ?name booksschema:hasGenre ?gender .
OPTIONAL {?name dcterms:title ?value}
}

--5
@prefix booksschema: <http://www.example.org/sprql-td/vocabs/> .
@prefix dcterms: <http://purl.org/dc/terms/>.

select ?name ?value where {
  ?name rdf:type booksschema:Book .
OPTIONAL {?name dcterms:title ?value}
FILTER(lang(?value)='fr')
}

--6
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix booksschema: <http://www.example.org/sprql-td/vocabs/> .


select * where {
  ?name rdf:type booksschema:Book .
  OPTIONAL { ?name booksschema:hasPrice ?price }
  FILTER(?price > 8) .
}

--7
@prefix booksschema: <http://www.example.org/sprql-td/vocabs/> .
@prefix dcterms: <http://purl.org/dc/terms/> .

select (count(?name) as ?PriceBooks) where {
  ?name rdf:type booksschema:Book
}

--8
@prefix booksschema: <http://www.example.org/sprql-td/vocabs/> .
@prefix dcterms: <http://purl.org/dc/terms/> .

select (count(?book) as ?nbBook) ?genre where {
  ?book booksschema:hasGenre ?genre
}
group by ?genre
having (?nbBook >= 2)

--9
@prefix booksschema: <http://www.example.org/sprql-td/vocabs/> .
@prefix dcterms: <http://purl.org/dc/terms/> .

select ?title ?author where {
    ?b dcterms:title ?title
    ?b dcterms:creator ?author
    filter(contains(LCase(?title), "contraire"))
}

--10
@prefix booksschema: <http://www.example.org/sprql-td/vocabs/> .
@prefix dcterms: <http://purl.org/dc/terms/> .

select ?title ?author {
    ?b dcterms:creator ?author .
    ?b dcterms:title ?title .
    {
        ?author foaf:name "Guillaume Musso".
    }
    UNION
    {
        ?author foaf:name "Melissa Da Costa".
    }
}

--11
@prefix booksschema: <http://www.example.org/sprql-td/vocabs/> .
@prefix dcterms: <http://purl.org/dc/terms/> .

select (avg(?price) as ?AvgPrice) where {
    ?book booksschema:hasPrice ?price
}



--12
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix books: <http://www.semanticWeb.org/sprql-td/> .


INSERT {
    ?book dcterms:creator books:siegel
}
WHERE {
    ?book dcterms:title ?title .
    FILTER(contains (?title, "5 Monde?"))
}

--13
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix booksschema: <http://www.example.org/sprql-td/vocabs/> .
@prefix books: <http://www.semanticWeb.org/sprql-td/> .

INSERT {
    ?book booksschema:hasPrice "15" .
} WHERE {
    ?book dcterms:creator ?author .
    ?author foaf:name "Melissa Da Costa" .
}


--14
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix booksschema: <http://www.example.org/sprql-td/vocabs/> .

@prefix books: <http://www.semanticWeb.org/sprql-td/> .

DELETE {
    ?book booksschema:hasPrice "15" .
}
INSERT {
    ?book booksschema:hasPrice "8" .
} WHERE {
    ?book dcterms:creator ?author .
    ?author foaf:name "Melissa Da Costa" .
}

