Your fact database is designed in such a way that one person could only participate in one subject (otherwise there is no way to know what marks are for what subject).
With this in mind, here is a simple modification of your code:
passed(Person, Subj):-
studies(Person, Subj),
marks(Person, Work, Exam),
Perc is Work*0.25 + Exam*0.75,
Perc >= 40.
Test run:
?- passed(X, Y).
X = julie,
Y = history ;
false.