The template query contains the code from the previous example. Modify it to show the revenue change as a percentage that's rounded to three decimal places.

Here's how you can count the revenue change as a percentage:

\frac{\textrm{total amount} - \textrm{total amount from preceding quarters}}{\textrm{total amount}} \cdot 100

Remember to round the result to three decimal places.

Use the following expression to calculate the last column:

ROUND(
100 *
(SUM(amount) - LAG(SUM(amount), 1)
OVER (ORDER BY EXTRACT(year FROM order_date),
EXTRACT(quarter FROM order_date)))
/ CAST(SUM(amount) AS decimal(10,2)),
3) AS delta