Re: format integer
От | ml@ft-c.de |
---|---|
Тема | Re: format integer |
Дата | |
Msg-id | 5d7a256d68909160e27856244f56f1f5dd7db61e.camel@ft-c.de обсуждение исходный текст |
Ответ на | Re: format integer ("David G. Johnston" <david.g.johnston@gmail.com>) |
Список | pgsql-sql |
On Sun, 2021-01-24 at 09:06 -0700, David G. Johnston wrote: > > On Sunday, January 24, 2021, <ml@ft-c.de> wrote: > > > > I need a integer format with different decimal places > > The integer should have 6 diggits. (or 7 or 8) > > > > > > No, there isn’t a function to apply this convoluted formatting rule > to non-integer numbers. You will need to write your own. > > David J. > My idea is SELECT round(1.2345678912, 5 - least(log(1.2345678912)::int,5) ); SELECT round(12.345678912, 5 - least(log(12.345678912)::int,5) ); SELECT round(123.45678912, 5 - least(log(123.45678912)::int,5) ); SELECT round(1234.5678912, 5 - least(log(1234.5678912)::int,5) ); SELECT round(12345.678912, 5 - least(log(12345.678912)::int,5) ); SELECT round(123456.78912, 5 - least(log(123456.78912)::int,5) ); SELECT round(1234567.8912, 5 - least(log(1234567.8912)::int,5) ); SELECT round(12345678.912, 5 - least(log(12345678.912)::int,5) ); SELECT round(123456789.12, 5 - least(log(123456789.12)::int,5) ); as content for a function with arguments (value numeric, diggits int) Have s.o. a better idea? Franz
В списке pgsql-sql по дате отправления: