Hello Farhana.

As I see it you you have at least the following options:


1)      Either build a huge logic expression with a lot of nested and's and 
or's. This should work for all SPRAQL 1.0 endpoints, but will be difficult to 
write and test.



2)      See how your endpoints reacts to the xsd:int(xsd:bool) constructor. You 
could then write expressions of the form: 
FILTER(xsd:int(cond1)+xsd:int(cond2)+---+xsd:int(condN)>=M), where cond[i] is 
any subexpression evaluating to a boolean value. I do not remember if this is 
covered by the SPARQL 1.0 standard, but might work depending on the SPARQL 
endpoint. (It works with the Clayster SPARQL endpoint we've developed.)


3)      If you can add external functions to your endpoint, create a function 
fn:BoolToInt(B) that returns the above.



4)      Process the extended logic on th client.


Sincerely,
Peter Waher

From: Farhana Sarker [mailto:[email protected]]
Sent: den 14 september 2011 16:06
To: [email protected]
Subject: Fwd: Request for help....

Could anyone help me please for my below request??


Best regards,
Farhana
---------- Forwarded message ----------
From: Farhana Sarker <[email protected]<mailto:[email protected]>>
Date: Tue, Sep 13, 2011 at 4:24 PM
Subject: Request for help....
To: [email protected]<mailto:[email protected]>


Hi,

I am a new SPARQL user.
I need to write a query using SPARQL which can be set conditions and will be 
able to return the value if AT LEAST 3 condition is TRUE.

For example:

I want to return all the id and other information from my datasets where 6 
conditions are given (as shown below) and want to retrieve information for whom 
at least ANY 3 conditions are TRUE. Could you please help me to write the query 
correctly as the below query returns for which all the conditions are TRUE.But 
I need to retrieve information for whom at least ANY 3 conditions are TRUE.

select ?id ?a ?b ?c ?d ?e ?f ?g
where {
             ?id myns:a ?a.
             filter (regex(?a, "professional")).
             ?id myns:b ?b.
             filter (?b = "P")
             ?id myns:c ?c.
             filter (?c != "UH")
             ?id myns:d ?d.
             filter (?d<2.7)
             ?id myns:e ?e.
             filter (?e<2.7)
             ?id myns:f ?f.
             filter (?f = "M")
             ?id myns:g ?g.
               filter (?g != "S")
  }


Thank you
Farhana

Reply via email to