Technical Assessment
Part 1
Using the following samples of tables, write a SQL query to answer the questions
below:
Questions
1. In which FOCUS CITY can you find the most expensive listing?
2. Calculate the average price of listings in each city, showing only cities where
the average price is greater than $1000.
Select c.city_name, avg(s.price) as exp_price
From listings s join cities c on s.city_id = c.city_id
Group by c.city_name
Having avg(s.price) > 1000
3. Calculate the difference between each listings’ price and the average price of
its city as a new column
Select s.listing_id, s.price - lag(s.price) over () as difference, avg(s.price) over
(partition by c.city_name)
From listings s left join cities c on s.city_id = c.city_id
Part 2
Using the following samples of tables, write a query to answer the questions below:
Questions
1. Get the latest price of each listing
2. You want to analyse price development. Calculate the average listing price per
month. Note: You need to take the price of a given listing in a given month.
Hint: The expected output should look like this: