One question about SQL [message #371] |
Thu, 07 February 2002 16:35 |
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 |
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
|
|
|