电影名最长的3部电影和他们的总销量是多少

Table: Movies (Read-Only)

Id Title Director Year Length_minutes
1 Toy Story John Lasseter 1995 81
2 A Bug's Life John Lasseter 1998 95
3 Toy Story 2 John Lasseter 1999 93
4 Monsters, Inc. Pete Docter 2001 92
5 Finding Nemo Finding Nemo 2003 107
6 The Incredibles Brad Bird 2004 116
7 Cars John Lasseter 2006 117
8 Ratatouille Brad Bird 2007 115
9 WALL-E Andrew Stanton 2008 104
10 Up Pete Docter 2009 101
11 Toy Story 3 Lee Unkrich 2010 103
12 Cars 2 John Lasseter 2011 120
13 Brave Brenda Chapman 2012 102
14 Monsters University Dan Scanlon 2013 110

Table: Boxoffice (Read-Only)

Movie_id Rating Domestic_sales International_sales
5 8.2 380843261 555900000
14 7.4 268492764 475066843
8 8 206445654 417277164
12 6.4 191452396 368400000
3 7.9 245852179 239163000
6 8 261441092 370001000
9 8.5 223808164 297503696
11 8.4 415004880 648167031
1 8.3 191796233 170162503
7 7.2 244082982 217900167
10 8.3 293004164 438338580
4 8.1 289916256 272900000
2 7.2 162798565 200600000
13 7.2 237283207 301700000

Table(表): Movies

Title Len TotalSales
Monsters University 19 743559607
The Incredibles 15 631442092
Monsters, Inc. 14 562816256

 

  1. 电影名最长的3部电影和他们的总销量是多少 ✓

select title,length(title)
as len,   (Domestic_sales + International_sales) as totalSales
from movies inner join boxoffice on movies.id = boxoffice.movie_id
order by len desc
 limit 3;

你可能感兴趣的:(SQL)