Tag Info

New answers tagged


To produce your desired output, you can simply: SELECT id, version FROM versions ORDER BY string_to_array(version, '.')::int[]; One can cast a whole text array to an integer array (to sort 9 before 10). One can ORDER BY array types. This is the same as ordering by each of the elements. SQL Fiddle (reusing @a_horse's fiddle, thanks!)


create extension semver; select id, version from SoftwareReleases order by version::semver; http://www.pgxn.org/dist/semver/doc/semver.html


select id, name, v[1] as major_version, v[2] as minor_version, v[3] as patch_level from ( select id, name, string_to_array(version, '.') as v from versions ) t order by v[1]::int desc, v[2]::int desc, v[3]::int desc; SQLFiddle: http://sqlfiddle.com/#!15/c9acb/1 If you expect more elements in the ...

Top 50 recent answers are included