Jay Fisher

Write three queries using outer joins

Task 3 Outer Joins in Konagora Chapter 3

  • December 6, 2017 at 12:50 PM
  • Visible to public
/*Task 3*/
/*Query 5 - Artists born after 1950 and are they still making movies within last 5 years*/
SELECT first_name, surname, born, UPPER(title) as 'Title' FROM people p LEFT JOIN (SELECT * FROM movies m INNER JOIN credits c ON m.movieid = c.movieid WHERE year_released > 2012) s ON  p.peopleid = s.peopleid WHERE p.born > 1949 ORDER BY p.surname asc;
/*Query 6 - French movies with alternate titles that are less than 20 characters long*/
SELECT UPPER(m.title) as 'Title', a.title as 'Alternate', m.year_released as 'Released'FROM movies m LEFT JOIN (SELECT * FROM alt_titles WHERE LENGTH(title)<20) a ON  m.movieid = a.movieid WHERE m.country="fr" ORDER BY m.title asc;
/*Query 7 - List all artists and if they have directed a movie in the US list the title(s)*/
SELECT first_name, surname, UPPER(title) as 'Title' FROM people p LEFT JOIN (SELECT * FROM movies m INNER JOIN credits c ON m.movieid = c.movieid WHERE country="us" AND c.credited_as="D") s ON  p.peopleid = s.peopleid  ORDER BY p.surname asc;