Gossamer Forum
Home : General : Databases and SQL :

sql problem

Quote Reply
sql problem
 
The question is:
display the names of the major with two highest number of students

related tables are
student ( std_code, std_name, maj_name, std_birthdate)
maj_adv ( adv_code, maj_name)

can someone help with this queriy?
Quote Reply
Re: [adash786] sql problem In reply to
try this:
Code:
SELECT COUNT(student.maj_name) AS hits, maj_adv.maj_name
FROM maj_adv, student
WHERE maj_adv.maj_name = student.maj_name
GROUP BY maj_adv.maj_name
ORDER BY hits DESC
LIMIT 2

Philip
------------------
Limecat is not pleased.