Sunday, March 25, 2012

Count function

I am using Oracle. Can anyone show me how to count distinctly for each Genre ID from following DATA?
GENRE_ID GENRE_DESCRIPTION MOVIE_ID
--- ------- -------
AC Action 1
DR Drama 1
TR Thriller 1
CO Comedy 2
RO Romance 2
CO Comedy 3
CR Crime 3
TR Thriller 3
AN Animation 4
CO Comedy 4
FA Family 4
AC Action 5
FY Fantasy 5
TR Thriller 5
AC Action 6
AD Adventure 6
FY Fantasy 6
HO Horror 7
MY Mystery 7
TR Thriller 7
AD Adventure 8
AN Animation 8
CO Comedy 8
CR Crime 9
DR Drama 9
HO Horror 100
MY Mystery 100
TR Thriller 100

What i want is something like this where it counts the numbers of Movie_id for each genre where there is no duplicate date for genre_id or movie_id.
Genre_ID Genre_Description Number of Movies
AC Action 2Hi,

Try this:
Select Genre_ID,Genre_Description,sum(movie_id) from table_name group by Genre_ID,Genre_Description;|||Please, move this tread to Oracle forum.

No comments:

Post a Comment