select city, title, releasedate movies join shownat on shownat.movietitle = movies.title join theatres on theatres.theatrename = shownat.theatrename group city, title, releasedate order city, max(releasedate) desc;
above query, , problem solve.
find titles of newest movies shown in each city. display city name , newest movie title ordered city name , movie title.
the normalized data has 3 tables called theatres, shownat , movies. yes, realize release date more efficient on shownat table, , me makes more sense because not videos released in same areas or cities @ same date. last homework problem stuck on. needed city should have 1 listing. thought group city take care of this. each city need title of movie has newest release date in each of particular cities(4) in data set. unsure why getting duplicates here when have group feature , use handle aggregate max function. max function should give me newest release yes?
"city" "title" "releasedate" "cincinnati" "interstellar" 07-nov-14 "cincinnati" "big hero 6" 07-nov-14 "cincinnati" "nightcrawler" 31-oct-14 "cincinnati" "gone girl" 03-oct-14 "cincinnati" "the pianist" 03-jan-03 "cincinnati" "fargo" 05-apr-96 "cincinnati" "schindler's list" 04-feb-94 "florence" "big hero 6" 07-nov-14 "florence" "interstellar" 07-nov-14 "florence" "nightcrawler" 31-oct-14 "florence" "gone girl" 03-oct-14 "florence" "district 9" 14-aug-09 "florence" "a perfect getaway" 07-aug-09 "florence" "aliens in attic" 31-jul-09 "florence" "away go" 26-jun-09 "florence" "up" 29-may-09 "florence" "star trek" 08-may-09 "florence" "the hurt locker" 10-oct-08 "florence" "the dark knight" 18-jul-08 "florence" "the departed" 06-oct-06 "florence" "the green mile" 10-dec-99 "newport" "interstellar" 07-nov-14 "newport" "big hero 6" 07-nov-14 "newport" "gone girl" 03-oct-14 "newport" "district 9" 14-aug-09 "newport" "a perfect getaway" 07-aug-09 "newport" "away go" 26-jun-09 "newport" "up" 29-may-09 "newport" "the departed" 06-oct-06 "wilder" "big hero 6" 07-nov-14 "wilder" "interstellar" 07-nov-14 "wilder" "gone girl" 03-oct-14 "wilder" "public enemies" 01-jul-09 "wilder" "the departed" 06-oct-06
this query i'm not quite sure if max function works date variable:
select city, title, max (releasedate) max_daterelease movies inner join shownat on shownat.movietitle = movies.title join theatres on theatres.theatrename = shownat.theatrename group city, title, releasedate order city, max_daterelease desc
Comments
Post a Comment