Sample Header Ad - 728x90

How can I sort by "release" in Mysql, where e.g. 10.10 comes after 10.9, with non-numerical entries both before and after?

1 vote
1 answer
47 views
If I have a table as per https://www.db-fiddle.com/f/arPEdUty3U6AJEQfqYEyRc/1 with a list of releases:
INSERT INTO releases (ReleaseID, ReleaseNumber) VALUES
(1, '10.6'),
(2, '10.8'),
(3, '_TBD'),
(4, '10.9'),
(5, 'Future'),
(6, '10.10'),
(7, '10.11');
How can I sort it so that things starting with _ come first, then numbers, ordered as 10.6, 10.8, 10.9, 10.10, 10.11, then anything else? My current casting attempt (CAST(ReleaseNumber as SIGNED INTEGER) puts Future after _TBD instead of at the end. The desired output of this example would be _TBD, 10.6, 10.8, 10.9, 10.10, 10.11, Future
Asked by Ben Holness (183 rep)
Sep 22, 2023, 06:53 PM
Last activity: Sep 24, 2023, 06:24 PM