All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bigdata.rdf.sparql.ast.eval.bsbm.bi.query5.rq Maven / Gradle / Ivy

There is a newer version: 2.1.4
Show newest version
# BSBM BI Q5
#
# Query 5: Show the most popular products of a specific product type for each country - by review count
#
# Use Case Motivation: For advertisement reasons the owners of the e-commerce platform want to generate profiles for the two dimensions product type and the country of a customer. 
#
# Note: xsd:string() => str()

prefix bsbm: 
prefix bsbm-inst: 
prefix rev: 
prefix xsd: 

Select ?country ?product ?nrOfReviews ?avgPrice
{
  { Select ?country (max(?nrOfReviews) As ?maxReviews)
    {
      { Select ?country ?product (count(?review) As ?nrOfReviews)
        {
          ?product a  .
          ?review bsbm:reviewFor ?product ;
                  rev:reviewer ?reviewer .
          ?reviewer bsbm:country ?country .
        }
        Group By ?country ?product
      }
    }
    Group By ?country
  }
  { 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:price ?price .
    }
    Group By ?product
  }
  { Select ?country ?product (count(?review) As ?nrOfReviews)
    {
      ?product a  .
      ?review bsbm:reviewFor ?product .
      ?review rev:reviewer ?reviewer .
      ?reviewer bsbm:country ?country .
    }
    Group By ?country ?product
  }
  FILTER(?nrOfReviews=?maxReviews)
}
Order By desc(?nrOfReviews) ?country ?product




© 2015 - 2024 Weber Informatics LLC | Privacy Policy