Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 11th November 2011
Braincode's Avatar
Braincode Braincode is offline
Ceriwis Addicted
 
Join Date: Nov 2011
Posts: 4,638
Rep Power: 20
Braincode mempunyai hidup yang Normal
Default [ask]SQL cendol inside

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..

thanks banget atas bantuannya..



Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


 


All times are GMT +7. The time now is 08:06 PM.


no new posts