I am having trouble doing a recursive query with sql. I wanted to know what is the best way to solve this.
I have the following model
where basically there are versions of applications, which are installed in different environments. It is important to note that each version has a previous version, so a model similar to the hotfix can be applied. To know the tickets that are in an environment, it is necessary to search for the latest version of the environment and make recursion
my goal is to build a table as follows:
ticket | arrival_date_to_enviroment | arrival_version_to_enviroment | enviroment
I suppose I have to do a recursive query, to know which tickets are in which version. For this I think that the first step would be to know the versions that a version includes I can do this part of the problem by posing something in the following way:
WITH RECURSIVE version_recursive AS (
select v.name, v.version_from, v.application from versions v
where v.name='21.1204.0'
UNION
select v.name, v.version_from, v.application from versions v
JOIN version_recursive s ON s.version_from = v.name AND s.application = v.application
)
SELECT *
FROM version_recursive;
the next step would be to find the latest deploy in the environment and join with tickets.
But one of my main problems is that I don't know how to complete arrival_version_to_enviroment using sql
I really appreciate any help and advice. I need to do this using sql, without programming logic
