Mam tabele:
STUDENT
student_id
name
sex
SCORE
student_id
event_id
score
EVENT
event_id
date
type
I teraz mam do wyświetlenia osobe która zdobyła najwiecej i osobe ktora zdobyla najmniej punktów, wiec:
SELECT name, type, score, sex FROM student, score, event WHERE student.student_id=score.student_id AND event.event_id=score.event_id AND score= (SELECT max(score) FROM score, event, student WHERE event.event_id=score.event_id) UNION SELECT name, type, score, sex FROM student, score, event WHERE student.student_id=score.student_id AND event.event_id=score.event_id AND score= (SELECT min(score) FROM score, event, student WHERE event.event_id=score.event_id) ORDER BY score
I w efekcie jest wyświetlany poprawny wynik. (jakby ktos umial inaczej - prosciej to wykonac prosze zademonstrowac)
A teraz drugie zapytanie:
Który mężczyzna (oznaczenie 'M') uzsykał najwiecej z ktory najmniej punktów z testu (oznaczenie 'T'):
SELECT name, type, score, sex FROM student, score, event WHERE student.student_id=score.student_id AND event.event_id=score.event_id AND sex='M' AND type='T' AND score= (SELECT max(score) FROM score, event, student WHERE event.event_id=score.event_id) UNION SELECT name, type, score, sex FROM student, score, event WHERE student.student_id=score.student_id AND event.event_id=score.event_id AND sex='M' AND type='T' AND score= (SELECT min(score) FROM score, event, student WHERE event.event_id=score.event_id) ORDER BY score
Prosze o wskazanie mi co jest źle w drugim zapytaniu bo mimo ze istenieja takie osoby nie wyświetla nic poza nazwami kolumn.
pzdr