Note that there can also be other correct solutions to the different tasks that those presented here.
SELECT *
FROM speciality;
SELECT distinct (sCity)
FROM student;
SELECT *
FROM student
WHERE sCity = 'Helsinki' and sSex = 'F';
SELECT tLname, tFname, tPhone
FROM teacher
WHERE tLname = 'Smith' and tFname = 'Susan';
SELECT *
FROM course
WHERE cCreditUnits = 3 and (cLectureHours 20 or
(cLectureHours + cPracticeHours 40));
SELECT cNumber, cName, ((cLectureHours * 600) +
(cPracticeHours * 300)) AS PRICE
FROM course;
SELECT (tLname||' '||tFname) AS NAME
FROM teacher
WHERE tPhone is null;
SELECT sLname, sFname, sYearBorn, sNumber
FROM student
WHERE sSex = 'M' and sCity = 'Espoo'
ORDER BY sYearBorn desc, sLname, sFname;
SELECT cName, round((cLectureHours + cPracticeHours) /
cCreditUnits) AS CRCOST
FROM course
ORDER BY CRCOST;
SELECT cName, cNumber,
to_char(csBeginDate,'DD.MM.YYYY') AS BEGINS
FROM course, courseschedule
WHERE cNumber = csCourse and csBeginDate between
'15-JAN-2000' and '15-MAR-2000';
SELECT tLname, tFname, spName
FROM teacher, teacherskills, speciality
WHERE tId = tsTeacher and tsSpeciality = spId
ORDER BY tLname, tFname, spName;
SELECT tLname, tFname, cName, tcTask, tcHours
FROM teacher, course, teaching
WHERE tLname = ´Edison´ and tFname = ´Thomas´ and
tId = tcTeacher and tcCourse = cNumber and
tcBeginDate between '1-JAN-2000' and '31-MAY-2000';
SELECT spName, suPhase, cName, cNumber
FROM course, suitability, speciality
WHERE spId = suSpeciality and suCourse = cNumber
ORDER BY spName, suPhase, cName;
SELECT sLname, sFname, sNumber
FROM student, studying s1, studying s2, course c1, course c2
WHERE (sNumber = s1.stStudent and s1.stCourse = c1.cNumber
and c1.cName = 'Network management')
and
(sNumber = s2.stStudent and s2.stCourse = c2.cNumber
and c2.cName = 'Object Modeling')
ORDER BY sLname, sFname, sNumber;
SELECT tLname, tFname, cName, cNumber,
to_char(t1.tcBeginDate,'DD.MM.YYYY') AS BDATE
FROM teacher, course, teaching t1, teaching t2
WHERE (tId = t1.tcTeacher and t1.tcCourse = cNumber
and t1.tcTask = 'lecture')
and
(tId = t2.tcTeacher and t2.tcCourse = cNumber
and t2.tcTask = 'practice')
and t1.tcBeginDate = t2.tcBeginDate;
SELECT sLname, sFname, sNumber, spname,
sfExtent, cName, suPhase
FROM student, studying, course, speciality,
suitability, studyfor
WHERE sNumber = stStudent and stCourse = cNumber and
sNumber = sfStudent and sfExtent = 'minor' and
sfSpeciality = spId and spId = suSpeciality and
suCourse = stCourse and suPhase = 'expert'
ORDER BY sLname, sFname;
SELECT tLname, tFname, cName, tcTask, tcHours,
to_char(tcBeginDate,'DD.MM.YYYY') AS BDATE
FROM teacher, course, teaching
WHERE tId = tcTeacher and tcCourse = cNumber and
tcBeginDate between '1-JAN-2000' and '31-MAR-2000'
ORDER BY tLname, tFname, BDATE;
SELECT sLname, sFname, sNumber
FROM student
WHERE sYearStarted <1998 and
sNumber not in (SELECT stStudent
FROM studying
WHERE stDatePassed is not null)
ORDER BY sLname, sFname;
>