com.bigdata.rdf.sparql.ast.eval.bsbm.bi.query8.rq Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bigdata-rdf-test Show documentation
Show all versions of bigdata-rdf-test Show documentation
Blazegraph(TM) RDF Test Suites
# BSBM BI Q8
#
# Query 8: Find 10 cheapest vendors for a specific product type by the highest percentage of their products below the average.
#
# Use Case Motivation: A vendor or customer wants to find "discounter" vendors for competitor analyses and procurement respectively.
#
# Note: xsd:string() => str()
prefix bsbm:
prefix bsbm-inst:
prefix xsd:
Select ?vendor (xsd:float(?belowAvg)/?offerCount As ?cheapExpensiveRatio)
{
{ Select ?vendor (count(?offer) As ?belowAvg)
{
{ ?product a .
?offer bsbm:product ?product .
?offer bsbm:vendor ?vendor .
?offer bsbm:price ?price .
{ Select ?product (avg(xsd:float(str(?price))) As ?avgPrice)
# { Select ?product (avg(xsd:float(xsd:string(?price))) As ?avgPrice)
{
?product a .
?offer bsbm:product ?product .
?offer bsbm:vendor ?vendor .
?offer bsbm:price ?price .
}
Group By ?product
}
} .
FILTER (xsd:float(str(?price)) < ?avgPrice)
# FILTER (xsd:float(xsd:string(?price)) < ?avgPrice)
}
Group By ?vendor
}
{ Select ?vendor (count(?offer) As ?offerCount)
{
?product a .
?offer bsbm:product ?product .
?offer bsbm:vendor ?vendor .
}
Group By ?vendor
}
}
Order by desc(xsd:float(?belowAvg)/?offerCount) ?vendor
limit 10
© 2015 - 2024 Weber Informatics LLC | Privacy Policy