Normal MAX function inn sql will get the maximum based on mathematical calculation.
For e.g. Max between
1.9 and 1.10 will return 1.9
But in case of release highest should be 1.10.
If we want to sort based on release numbers and get the maximum then we have to create a custom sql function and get the maximum. For this we will LPAD the release number by replacing each number after/replacing each "." with some specific number of 0. After that we can check for max number and return it.
CREATE OR REPLACE FUNCTION MAX_RELEASE_VERSION(release_version IN VARCHAR2)
RETURN VARCHAR2 AS
sub_string VARCHAR2(50);
BEGIN
FOR char_value IN
(SELECT LPAD(regexp_substr(release_version,'[^.]+', 1, level),4,'0') as splited_num FROM DUAL CONNECT BY regexp_substr(release_version, '[^.]+', 1, level) IS NOT null)
LOOP
sub_string:=sub_string || char_value.splited_num;
END LOOP;
RETURN sub_string;
END;
/