I have a column that contains a version number as string like:
- 2.7.0.0
- 2.6.12.0
- 3.30.3.0
- many more
How can I select all entries that have a version number lower than 2.7.0.0?
Since my last question got closed because the obviouse answere to my question is this:
WITH split(word, str) AS (
SELECT '', '2.7.0.0'||'.'
UNION ALL SELECT
substr(str, 0, instr(str, '.')),
substr(str, instr(str, '.')+1)
FROM split WHERE str!=''
) SELECT word FROM split WHERE word!='';
I have multiple questions to that:
- This Example just splits a string at
.
. How can I build that into a query and not just hardcode a string into it?. (Tryed to replace'2.7.0.0'
with(select version from software)
without luck) - Where do I need to put the version
2.7.0.0
to compare it to in this query?
Edit:
I got it to work with only the first number:
select version from software where (
select word as major from (WITH split(word, str) AS (
SELECT '', version||'.'
UNION ALL SELECT
substr(str, 0, instr(str, '.')),
substr(str, instr(str, '.')+1)
FROM split WHERE str!=''
) SELECT word FROM split WHERE word!='' LIMIT 1) where word = "2"
)