0

:rolleyes:

Hi,
I am new to PLSQL and I have to answer three questions to which I tried my best but i could not do it any more please help.
Here are the tables and the data:
TABLE FACULTY_P( faculty_id, fac_name, office, salary);
TABLE STUDENT_P( student_id, std_name, home_phone, total_credits, gpa, advisor_id );
TABLE COURSE_P( course#, credit_hours, location, faculty_id);
TABLE ENROLLMENT_P(student_id, course#, grade);
Here is the first question:
Give the student name and the gpa for the student with the highest gpa than all colleagues with the same total credit hours,
I wrote the following: select std_name, gpa
from student_p s, course_p c1, course_p c2
where c1.credit_hours = c2. credit_hours
having max(gpa);
I wrote several statement none of them worked.
Second Question:
For each student name the list course numbers that the student obtained the lowest grade
Iwrote the following: select course# from Enrollment_p e1, Enrollment_p e2 where e1.course# = e2.course# and e1.grade < e2.grade;
Statement not working either.
Third question: Give the names of faculty who do not advise any students.
I wrote: select fac_name from faculty_p f, student_p s where
f.faculty_id <> s.advisor_id;
Not working either.
Please i need your help it is urgent that i solve this before tuesday.
Thank you for your help
Dounia

2
Contributors
1
Reply
2
Views
12 Years
Discussion Span
Last Post by Phaelax
0

I think you're making things too hard for yourself.

select std_name, gpa
from student_p
where total_credits = max(totale_credits);


student_p has the "total_credits" field in it, so you don't even need to calculate the credit total yourself by searching through course_p.(which you'd need to use enrollment_p as well)

Hopefully the code above will help you with the second question. You should not have to state the same table name twice in a FROM clause.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.