Complete the code to register the DataFrame as a temporary SQL view named 'people'.
df.[1]('people')
The method createOrReplaceTempView registers the DataFrame as a temporary view for SQL queries.
Complete the code to run a SQL query selecting all columns from the 'people' view.
result = spark.sql('SELECT [1] FROM people')
The asterisk (*) selects all columns in SQL queries.
Fix the error in the SQL query to select people older than 30.
result = spark.sql('SELECT * FROM people WHERE age [1] 30')
In SQL, the greater than operator is >. The double equals == is not valid in SQL.
Fill both blanks to select distinct cities from the 'people' view and order them alphabetically.
result = spark.sql('SELECT [1] city FROM people ORDER BY city [2]')
DISTINCT selects unique cities, and ASC orders them alphabetically ascending.
Fill all three blanks to count the number of people in each city, grouping by city and ordering by count descending.
result = spark.sql('SELECT [1], COUNT(*) as [2] FROM people GROUP BY [3] ORDER BY [2] DESC')
Select the city, count the rows as 'count', group by city, and order by count descending.