Exponential number formatting PostgresQL

Viewed 908

I have a column called card_number (table = customer) and the entries are displayed exponentially, like the entries listed below:

4.56E+15

4.54E+15

4.56E+15

5.39E+15

4.49E+15

Can someone help me formatting every entry of the column to a 16 digit entry? (Still has to be datatype varchar)

I'd be very thankful if someone could help me with this...

Thanks for your time!

2 Answers

Please use below type casting while selecting the column,

select card_number::decimal(38,0) from customer;

If you want the result as string, that could be

to_char(CAST(card_number AS numeric), '999999999999999999999999999FM')
Related