2015-09-14 38 views
1

此SUM聚合函數不起作用。它沒有結果。SPARQL中的SUM函數

select (SUM(?p) as ?prcc) ?sune 

where { 

?inl Sp:hasp ?p. 

    ?inl Sp:hassuid ?supid. 

?supid Sp:hassune ?sune. 

} 
GROUP BY ?sune 

「p」中的數據爲雙格式。因此,當我將我的查詢更改爲

select (SUM(xsd:double(?p)) as ?prcc) ?sune 

or select (SUM(xsd:integer(?p)) as ?prcc) ?sune 

它不對帶小數點的值執行SUM。

+3

請顯示一些樣本三元組 –

+3

**「p」中的數據是雙重格式**您的意思是文字實際上是數據類型文字,數據類型爲xsd:double,或者它們是字符爲字符的字符串適合xsd:double的詞法形式?正如@TomaszPluskiewicz所說,你需要顯示一些數據,否則我們無法真正幫助。 –

回答

1
select (SUM(?p)) 
WHERE 
{ 
    VALUES (?p) { 
     (10.5) 
     (20.5) 
    } 
} 

我想這對在線編輯器SPARQL online editor它的工作原理fine..may爲u可以嘗試在你的樣本數據。