0

Currently I have a working To_Char in Oracle:

To_Char($Num,'FM' || RPAD(RPAD(LPAD(LPAD('.',least($intmaxlength,$intminlength)+1,'0'),$intmaxlength+‌​1,'9'),$intmaxlength+1+$decminlength,'0'),$intmaxlength+1+$decmaxlength,'9'))

My goal is to convert a number to a string, fitting into four parameters for integers and decimals.

I would like to add minimum and maximum precision. For example, the integers to the left of the decimal point in 1234567.89 should have a minimum of 1 but a maximum of five (so the extra integers would be trimmed). In addition, I'd like to do the same for scale - the decimals to the right, by setting a minimum of two decimal places and a maximum of four. These numbers are just examples, the numbers will be updated dynamically.

I have minimal experience in MSSQL, but from what I can see some equivalent functions like Least are missing in it versus Oracle.

Avi
  • 3
  • 1
  • 4

1 Answers1

0

Here are string functions for MSQL

https://msdn.microsoft.com/en-us/library/ms181984.aspx

for least i dont think there is any equivalent.

But i found this getting-the-minimum-of-two-values-in-sql

Community
  • 1
  • 1
Juan Carlos Oropeza
  • 47,252
  • 12
  • 78
  • 118
  • Thanks for replying Juan Carlos! The links were helpful but there are 26 scalar functions - which ones do you think are the most appropriate for what I'm trying to do? – Avi Jul 24 '15 at 16:56
  • I didnt try to understand your issue. Maybe you could improve your answer with a more detail sample of what you are trying to do. Also i recomend you read [How Ask Better Question](http://stackoverflow.com/help/how-to-ask) – Juan Carlos Oropeza Jul 24 '15 at 18:07