我有这个sparql查询:

SELECT DISTINCT (COUNT(?bw) AS ?total) (COUNT(?bw_bad) AS ?total_bad) WHERE
{
{
    SELECT ?bw WHERE
    {
         ?bw unt:has_bwid ?id
    }
}
UNION
{
    SELECT ?bw_bad WHERE
    {
      ?bw_bad unt:has_rbdname ?rbd_name_bad .
      ?bw_bad unt:has_concie_0 ?concie_0 .
      FILTER(?concie_0 > 40)
    }
}
}


这使:

total                                              total_bad
"2155"^^<http://www.w3.org/2001/XMLSchema#integer>  "46"^^<http://www.w3.org/2001/XMLSchema#integer>


我想计算它们的百分比,这将得出(46/2155 * 100)2.13%。我该怎么做?我不在乎性能。



我的尝试:

SELECT ((COUNT(?bw_bad) AS ?total_bad)/(COUNT(?bw) AS ?total)*100) WHERE


这给出了此语法错误:


在第10行第34列遇到了““ as”“ AS”“。期待以下其中之一:”)“ ...” =“ ...”!=“ ...”>“ ...” =” ...“ ||” ...“ &&” ...“ +” ...“-” ...“ *” ...“ /” ...“ in” ...“ not in” ... ...。 .. ... ... ... ...

最佳答案

更改此:

SELECT ((COUNT(?bw_bad) AS ?total_bad)/(COUNT(?bw) AS ?total)*100) WHERE


对此:

SELECT (COUNT(?bw_bad)* 100 / (COUNT(?bw)) as ?total) WHERE

关于geometry - 来自两个COUNT的百分比,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36523672/

10-10 06:47