Question

Select Title, Retail, Cost,
  Concat(Round((Retail-Cost)/Cost*100, 0), '%') "Profit"
From BOOKS;

I am doing this for an assignment. It does exactly as it is suppose to. The table displays the information just right except for one small detail. The Profit column is left justified I want it to be right justified. I have tried to apply a LPAD to it but like this Lpad (Concat(Round((Retail-Cost)/Cost*100, 0), '%') "Profit", 5, ' ') but I keep getting an error that I'm missing a right ) around the "Profit" area. How do I get the alias column to be right justified?

Was it helpful?

Solution

You just need the alias after all the manipulation:

Lpad (Concat(Round((Retail-Cost)/Cost*100, 0), '%'), 5, ' ') "Profit"

The 'missing right parenthesis' error usually doesn't literally mean that the parentheses are unbalanced - that you have more left than right. It's that it's expecting to see one in a particular place and saw something else, that it didn't understand. In this case that's seeing the double-quoted alias identifier "Profit" where it's expecting to see the the next part of the lpad syntax.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top