Home » RDBMS Server » Server Administration » One question about SQL
One question about SQL [message #49755] Thu, 07 February 2002 16:35 Go to next message
Chen Wen
Messages: 26
Registered: February 2002
Junior Member
There are two tables:
table "enrolled":
SIDN SECT CREDITS
----- ----- ---------
11111 B411 2
22222 B332 3
11111 B412 3
22222 B412 4
33333 B412 3

Table "student":
SIDN MAJO NAME
----- ---- -------------
11111 PHIL King, Patrick
22222 CSCI Winn, William
33333 ENGR Smith, John

How to list all students' names, how many classes,
and how many credit hours they are taking?
Re: One question about SQL [message #49894 is a reply to message #49755] Fri, 15 February 2002 20:24 Go to previous message
nash
Messages: 10
Registered: February 2002
Junior Member
Chen,

Select s.Name as Name,
count(e.Sect) as numberOfClasses,
sum(e.Credits) as totalCredits
From student s,
enrolled e
Where e.SIDN = s.SIDN
Group by s.name

Result:

Name numberOfClasses totalCredits
-------------------- --------------- ------------
King, Patrick 2 5
Smith, John 1 3
Winn, William 2 7

I hope this is what you were looking for.

Nash
Previous Topic: Oracle 9i and the Text datatype
Next Topic: Re: free ocp papers
Goto Forum:
  


Current Time: Tue Dec 24 12:00:03 CST 2024