Table Student has 3 columns,Student_id,Student_Name &
Course_Id. Table Course has 2 columns, Course_Id &
Course_Name.Write a query to listdown all the Courses and
number of student in each course.

Answer Posted / kalyan

SELECT COURSE_NAME,COUNT(B.STUDENT_ID) NO_OF_STUDENTS
FROM COURSE A LEFT OUTER JOIN STUDENT B
USING (COURSE_ID)
GROUP BY A.COURSE_NAME

OR

SELECT COURSE_NAME,COUNT(B.STUDENT_ID) NO_OF_STUDENTS
FROM COURSE A , STUDENT B
WHERE A.COURSE_ID = B.COURSE_ID(+)
GROUP BY A.COURSE_NAME

This will list all the courses with no of students

Is This Answer Correct ?    8 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a full join sql?

662


What is t sql used for?

605


How to run sql statements through the web interface?

604


What is the main difference between sql and pl/sql?

628


What is the difference between local variables and global variables?

670






What do you understand by pl/sql records?

599


Differentiate between % rowtype and type record.

806


what is a trigger in mysql? : Sql dba

668


how to convert numeric values to character strings? : Sql dba

634


What is the sql query to display the current date?

611


what are set operators in sql? : Sql dba

601


Why do we use triggers?

591


Differences between Oracle 9i and 10g (Probably in terms of SQL and PL/SQL)?

3169


Write a query to find the names of users that begin with "um" in sql?

570


What does select * from mean in sql?

2217