Skip to content
Advertisement

Dummy Column in SQL Query

I am working on a SQL query and I need to do a calculation and store the result in dummy column in the output.

I am doing the calculation as shown above however I am still missing something. Any help will be greatly appreciated.

Advertisement

Answer

SQL doesn’t allow for you to do computation on data being computed in the same query. As there is already an example with a CTE, here is what the subquery version might look like…

There are pros/cons between CTE and Subquery methods that you might consider depending on your specific case. You can read about it here Difference between CTE and SubQuery?

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement