# BSBM Explore Query 10: Get offers for a given product which fulfill specific requirements.
#
# Use Case Motivation: The consumer wants to buy from a vendor in the United States that is able to deliver within 3 days and is looking for the cheapest offer that fulfills these requirements.
#
#    uses DISTINCT
#    uses ORDER BY and LIMIT

PREFIX bsbm: <http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>

SELECT DISTINCT ?offer ?price
WHERE {
        ?offer bsbm:product <http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/dataFromProducer1/Product10> .
        ?offer bsbm:vendor ?vendor .
    ?offer dc:publisher ?vendor .
        ?vendor bsbm:country <http://downlode.org/rdf/iso-3166/countries#US> .
        ?offer bsbm:deliveryDays ?deliveryDays .
        FILTER (?deliveryDays <= 3)
        ?offer bsbm:price ?price .
    ?offer bsbm:validTo ?date .
    FILTER (?date > "2008-06-20T00:00:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> )
}
ORDER BY xsd:double(str(?price))
LIMIT 10
