Hi all,

I'm trying to perform sparql query to find <video_id, category, score>
triples with an union
aggregating all the matching scores over a video_id.
However, the score is returned as blank. Here's how I construct the query

select ?v (sum(?s99*2+?s0) AS ?ss) where {
 { ?v <http://onescreen.com/video_freebase#/music/track>  ?s99 }
union
 { ?v <http://onescreen.com/video_freebase#/music>  ?s0 }
} group by ?v order by desc (?ss) limit 100

---------------------------------------------
| v                                    | ss |
=============================================
| <http://onescreen.com/video#1732760> |    |
| <http://onescreen.com/video#1732780> |    |
| <http://onescreen.com/video#1732800> |    |


but selecting with the specific video_id, the record does have both, but on
different columns:

select ?s0 ?s99 where {
 { <http://onescreen.com/video#1732760> <
http://onescreen.com/video_freebase#/music>  ?s0 }
union
{ <http://onescreen.com/video#1732760> <
http://onescreen.com/video_freebase#/music/track>  ?s99 }
}

-------------------------------------------------------------------------------------------------------------
| s0                                                  | s99
                                     |
=============================================================================================================
| "0.01532"^^<http://www.w3.org/2001/XMLSchema#float> |
                                     |
|                                                     |
"0.00739"^^<http://www.w3.org/2001/XMLSchema#float> |
-------------------------------------------------------------------------------------------------------------

looks like it is caused by blank variable, either sum() or + with a blank
causes the result to be blank.
I noticed that I couldn't map the two columns into the same variable name,
as I'd like to apply different weights ?s99 and ?s0
to achieve sum(?s99*2+?s0)

so, with which function could I make a variable to be 0 when it is blank?
what is the correct way to construct this query?


Thank you.

Yuhan

Reply via email to