AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Postgres convert string to number8/25/2023 ![]() You could do that with plpgsql, or kludge a regexp: select regexp_replace( ![]() If you don't want leading zeros in your labels, then you need to make a function that will add them on the fly. If you want to order them alphabetically, then a quick solution is to do it like ISO dates: 'Disk 01' indeed comes before 'Disk 10' because alphabetically '0' < '1'. ![]() I want and expect: DISK 1, DISK 2, DISK 3, DISK 10 With quotes meaning 'this is a text literal', '10' < '2' indeed. Numbers are letters too, and they sort alphabetically. This is not what you want, but it is the correct order when sorting text. However, it is built into ICU, and more and more systems are integrating ICU. ** To be fair, ICU / Unicode isn't "required" for doing this type of sorting, given that any collation or system can implement the same algorithm.
0 Comments
Read More
Leave a Reply. |