Solution Review: Implement Business Logic
Understand how to strategically implement business logic within PostgreSQL queries. Learn to use SELECT, JOIN, WHERE, and GROUP BY clauses to retrieve and aggregate data according to application needs.
We'll cover the following...
We'll cover the following...
Solution
The solution for the challenge is given below. Click the “Run” button in the following widget and see the output of the code.
/***************************************************/
/***** The query to *****/
/***** retrieve the albums along with *****/
/***** the size using business logic *****/
/***************************************************/
select album.title as album, SUM(bytes) as size
from track
join album using(albumid)
where track.albumid = 7
group by album.title;
/***************************************************/Code to calculate storage size
Explanation
Following is the explanation of the challenge: