SELECT result.assignment, 
	result.type AS typeid, 
	resulttype.name AS type, 
	result.step AS stepid, 
	resultstep.name AS step, 
	result.updatedon,
	obs_concl.value AS conclusion,
	obs_mark.value AS mark_value,
	obs_decision.value AS decision,
	obs_decision_ex.value AS decision_ex
FROM resulttype,resultstep,result 
	LEFT OUTER JOIN observation AS obs_concl ON obs_concl.assignment = result.assignment 
		AND obs_concl.restype = result.type 
		AND obs_concl.resstep = result.step 
		AND obs_concl.type = (SELECT id FROM observationtype WHERE name = 'conclusion') 
	LEFT OUTER JOIN observation AS obs_mark ON obs_mark.assignment = result.assignment 
		AND obs_mark.restype = result.type 
		AND obs_mark.resstep = result.step 
		AND obs_mark.type = (SELECT id FROM observationtype WHERE name = 'mark-value') 
	LEFT OUTER JOIN observation AS obs_decision ON obs_decision.assignment = result.assignment 
		AND obs_decision.restype = result.type 
		AND obs_decision.resstep = result.step 
		AND obs_decision.type = (SELECT id FROM observationtype WHERE name = 'comparison-decision') 
	LEFT OUTER JOIN observation AS obs_decision_ex ON obs_decision_ex.assignment = result.assignment 
		AND obs_decision_ex.restype = result.type 
		AND obs_decision_ex.resstep = result.step 
		AND obs_decision_ex.type = (SELECT id FROM observationtype WHERE name = 'comparison-decision-ex') 
WHERE result.type = resulttype.id 
	AND result.step = resultstep.id
