Home » SQL & PL/SQL » SQL & PL/SQL » One question about SQL
One question about SQL [message #371] 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 #372 is a reply to message #371] Thu, 07 February 2002 16:44 Go to previous message
seng
Messages: 191
Registered: February 2002
Senior Member
******
select a. sidn,a.name,sum(a.credits),count(b.sect)from sudent a, enrolled b
where a.sidn = b.sidn
group by a. sidn,a.name.

I think this statement will give u how many classes and credits. If this is not working,please use below statement

*****
select a.name,sum(a.credits),count(b.sect)from sudent a, enrolled b
where a.sidn = b.sidn
group by a.name.

This might be wrong because i need database to create this statement. thanks
Previous Topic: View, Not Exists, ... H E L P Please...
Next Topic: Help in Cursor!!!!
Goto Forum:
  


Current Time: Fri Apr 26 12:56:18 CDT 2024