> Hello Rob, > > We are in a group and we discussed it. > > We have three data properties , CryptographyScore, SoftwareEngineering > score and NetworkingScore and we need the maximum of these three scores for > a student. > > Can we do it like this > > SELECT ?student (MAX(?score1, ?score2, ?score3) AS ?topScore) > No, Rob almost showed the solution. It's not allowed and I also don't see why you want to use 3 variables in the MAX function.
Again, we assume that you want to get the maximum score among all students for a particular subject! That means, the query would be (for CryptographyScore here only) PREFIX ex: <http://example.com/ns/> SELECT (MAX(?score) AS ?topScore) WHERE { ?student ex:CryptographyScore ?score . } You asked the same question on Stackoverflow by the way and I told you there to use SPARQL qith aggregate functions. I assume that you're a group of CS students, so you should know about SQL which also supports GROUP BY + aggregate functions. The principle is the same. > > > On Wed, Jan 4, 2017 at 5:05 PM, Rob Vesse <[email protected]> wrote: > >> Most likely not >> >> You seem to be running into the XY problem a lot (http://xyproblem.info) >> >> You keep asking how to do things with rules for which rules are not really >> designed. And from some of your responses it sounds like the problems >> you’re trying to solve don’t actually need rules at all. >> >> For example finding the top score for a student would be much more easily >> done with a SPARQL query although from what little I have seen of your data >> model it looks like it would make it even that quite awkward. But in >> general terms something like the following would work: >> >> PREFIX ex: <http://example.com/ns/> >> SELECT ?student (MAX(?score) AS ?topScore) >> WHERE >> { >> ?student ex:score ?score . >> } >> GROUP BY ?student >> >> Rob >> >> On 04/01/2017 13:25, "javed khan" <[email protected]> wrote: >> >> Thanks Dave and Lorenz for your response. >> >> What if we have entered the score for a student in Cryptography and >> SoftwareEngineering and did not entered for Networking subject and >> stored >> something like this in our owl file: >> >> Student1 >> >> Name: Bob >> CryptographyScore: 60 >> SoftwareEngineeringScore: 80 >> //NetworkingScore, not mentioned here >> >> Then will the above rule fires? >> >> >> >> On Wed, Jan 4, 2017 at 11:35 AM, Lorenz B. < >> [email protected]> wrote: >> >> > Inline comments: >> > > I have three subjects marks for a student. >> > > Cryptography, Networking, Software Engineering with different >> marks for >> > > each student. >> > > I want to calculate in which subject a student got maximum marks >> using >> > Jena >> > > rule and will set that subject as HighScoreSubject of the student ( >> > > HighScoreSubject is data propety) whose values will be one of >> these three >> > > subjects. >> > > >> > > Is this rule correct to get the required result ( I am asking this >> > because >> > > I am not getting the result required) >> > Without seeing the data, it's always difficult to say if something is >> > correct or not. Sample data makes things easier. >> > And without knowing how you apply the rules (in a correct syntax) >> it's >> > even harder. That means, it's always good to show the relevant code. >> > > >> > > ?x rdf:type std:Student + ?x std:CryptographyScore ?score1 + ?x >> > > std:NetworkingScore ?score2 + ?x std:SEScore ?score3 + >> > > greaterThan(?score1,?score2), greaterThan(?score1, ?score3) --> >> > > ?x std:HighScoreSubject std:Cryptography >> > > >> > This rule covers only the case when the score for Cryptography is the >> > highest. If your data doesn't contain a student that matches the >> rule, >> > nothing will happen. >> > >> > >> > Cheers, >> > Lorenz >> > >> > -- >> > Lorenz Bühmann >> > AKSW group, University of Leipzig >> > Group: http://aksw.org - semantic web research center >> > >> > >> > >> >> >> >> >> >>
