Home » SQL & PL/SQL » SQL & PL/SQL » group by problem, another one...
group by problem, another one... [message #212311] Thu, 04 January 2007 11:30 Go to next message
montreal
Messages: 5
Registered: January 2007
Location: Montreal
Junior Member
Hello,

something very simple I can do with Mysql that I don't know how to do with Oracle...

Let's say I have a table "movie" and a table "time" :

table "movie" has the id_movie and the movie_name :
1 - Movie1
2- Movie2

table "time" has the id_movie and the time :
1 - 1pm
1 - 3pm
1 - 8pm
2 - 2pm
2 - 4pm

How can I get the name of all movies with their earliest time ? The result should be :
Movie1- 1pm
Movie2- 2pm

In Mysql, I would use a group by :
SELECT movie_name, time FROM from movie, time WHERE movie.id_movie = time.id_movie GROUP BY movie.id_movie ORDER BY time ASC

If I use group by in Oracle, I get all the movies and times !

Thanks !!

Helene









Re: group by problem, another one... [message #212316 is a reply to message #212311] Thu, 04 January 2007 12:12 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
SELECT m.name, MIN(t.hrs)
FROM movie m, time_table t
WHERE m.id = t.id
GROUP BY m.name;
Re: group by problem, another one... [message #212326 is a reply to message #212316] Thu, 04 January 2007 13:00 Go to previous message
montreal
Messages: 5
Registered: January 2007
Location: Montreal
Junior Member
thanks a lot !!
Previous Topic: perfect square
Next Topic: SUBQUERY QUESTION
Goto Forum:
  


Current Time: Sun Dec 11 08:24:04 CST 2016

Total time taken to generate the page: 0.06764 seconds