PostgreSQL – How to use CTE



PostgreSQL – How to use CTE

PostgreSQL - How to use CTE

How to wrap an existing SQL Statement with a CTE.

Use CTE to compute the Total Sales, Total Investment, and Total Profit Or Loss for the DVD Rentals sample database.

Using a CTE can make your SQL Statement easier to read and understand, especially if you don’t look at it for several years, and then come back to make a change.

So, I made this video for you. I hope you’ll be able to implement what you learned here, without the struggle I went through when I was first learning about using the Common Table Expression (CTE).

How to compute investment for each DVD.
How to compute Gross Sales for each DVD.
How to compute Profit or Loss for each DVD.

Then, using a CTE, create a one row total of Investment, Gross Sales, Profit/Loss.

Common Table Expression.

#softwarenuggets, #postgres, #postgresql

Comments are closed.