views:

27

answers:

1

I have a table course:

CREATE TABLE course
    (COURSE_NO NUMERIC(8,0) NOT NULL
    ,DESCRIPTION VARCHAR(50) 
    ,COST NUMERIC(9,2) 
    ,PREREQUISITE NUMERIC(8,0)
    ,CREATED_BY VARCHAR(30) 
    ,CREATED_DATE DATE 
    ,MODIFIED_BY VARCHAR(30) 
    ,MODIFIED_DATE DATE 
    ,PRIMARY KEY (COURSE_NO)
    ,INDEX (PREREQUISITE)
    ) TYPE = INNODB;

I want to retrieve prerequisites and display the number of courses it is a prerequisite of

So far i understand i have to count the number of prerequisites a course has, but i dont understand how to display a count for each prerequisite.

Any help with this select statement would be appreciated.

Thanks, Mike

+2  A: 

Assuming my comment is correct, this should work:

SELECT COUNT(*), prerequisite FROM course GROUP BY prerequisite;
wsorenson
read the question again.
Murali VP
done. what new insight shall I have received?
wsorenson