PDA

View Full Version : [ask]SQL cendol inside


Braincode
11th November 2011, 01:19 PM
bro gua mau tanya query SQl language ne.. koq klo bikin bahasa sql gini otak gua suka ga jalan sih.. :((



gini contohnya bro..



Consider the following database schema:

course(course#, dept-name)

enroll(studentID, course#, status)



1.Write a SQL query that finds the studentIDof all students who are enrolled in at least one course offered by CS department and are not enrolled in any courses offered by EE department.



2.Write a SQL query that lists the course# of all the courses for which more than 50 students are enrolled.



3.Write a SQL query that finds the studentIDof all the students who are enrolled in the maximum number of courses. (For example, suppose there are 3 students, each is enrolled in 5 courses, and all other students are enrolled in fewer than 5 courses. Then you are expected to return the studentsIDof these 3 students.)



jawaban gua :


Quote:





1.Select e.StudentID

From enroll e

Where EXISTS ((Select c.course

FROM course C

Where e.course=c.course AND c.dep-name = CS)

Except

(select c.course

FROM course c

Where e.course=c.course AND c.dept-name=EE))



2.SELECT e.course

From enroll e

Group BY StudentID

Having COUNT(STudentID) > 50





3.Pusink lagi bro.. :((








bener ga sih bro jawaban gua.. klo salah kenapa salah.. :D

thanks banget atas bantuannya.. :D

</div>