Assignment
University
California State UniversityCourse
IS 441 | Database Management SystemsPages
2
Academic year
2023
Alicia Webb
Views
0
08/09/2023 Answer this question below. 1. Make a SQL Query to display 5 cities with the highest total revenue Answer : select c.city_id, c.city, sum(p.amount) as total_revenue from address a left join city c on a.city_id = c.city_id left join customer c2 on c2.address_id = a.address_id left join rental r on r.customer_id = c2.customer_id left join payment p on r.rental_id = p.rental_id group by c.city_id, c.city having sum(p.amount) is not null order by 3 desc limit 5; Here’s the output when we run the query : 2. Make a SQL Query to show how much amount in the weekend. Answer : select sum(p.amount) from payment p where extract (isodow from p.payment_date) between 6 and 7
Here’s the output when we run the query :
PostgreSQL Practice #6
Please or to post comments