I have a database table with these two columns:
- Amount: numeric (18,0)
- DecimalPlaces: numeric (18,0)
This table can store amounts in various currencies, with the decimal place removed from the amount (I can't change this data model). For example, there might be two rows like this:
- 1290, 2 (This is £12.90, needs to appear as "12.90")
- 3400, 0 (This is 3400 Japanese Yen, needs to appear as "3400")
I need an SQL query for both Oracle and SQL Server that will format each amount with the correct number of decimal places, preserving any trailing zeroes as illustrated above. I can't use stored procedures, a reporting tool, or Excel.