Problems with CTE
Easy
15
1
66.2% Acceptance
Mia was attempting to solve an SQL challenge, the query written by her doesn't seem to pass all the test cases, can you help Mia figure out what's wrong with her query and fix it?
The below text is the Instructions written for the SQL challenge that Mia is solving.
Create a chain of three Common Table Expressions (CTEs) to perform successive transformations on the invoice data.
Table to be used: Invoice
Instructions:
- Use the
Invoice
table from the Chinook database. - Create a sequence of three CTEs.
- The first CTE (
CTE1
) should take theTotal
column from theInvoice
table and multiply it by 1.1, naming this new columnTransformedTotal1
. - The second CTE (
CTE2
) should take theTransformedTotal1
column fromCTE1
and multiply it by 0.9, naming this new columnTransformedTotal2
. - The third CTE (
CTE3
) should take theTransformedTotal2
column fromCTE2
and multiply it by 1.05, naming this new columnTransformedTotal
. - The final output should have the columns:
InvoiceId
: Represents the ID of the invoice.TransformedTotal
: The final transformed total after all the operations performed in the CTEs.
- The results should be ordered by the
InvoiceId
in ascending order.
Expected Columns in Final Output:
InvoiceId
TransformedTotal
Order By: InvoiceId