I have this sparql query that I need to modify. I have the example instance, which has the exampleID 12345. For this case, if the :hasRelatedExample connection exists, the ?test variable will become 2. If the :hasRelatedExample connection doesn't exist from the example instance, the ?test variable doesn't get assigned the 1 value as it should. How could I fix this query to reflect the needed behavior?
PREFIX : <http://www.example.com#>
Select distinct ?test
where
{
?ex a :Example ;
:exampleID "12345" ;
:hasRelatedExample ?relatedExample .
BIND (IF(BOUND(?relatedExample),2,1) as ?test)
}