/*A recursive query is one that is defined by a Union All with an initialization
fullselect that seeds the recursion. The iterative fullselect contains a direct
reference to itself in the FROM clause. */
Read Here :
https://www.ibm.com/docs/en/i/7.4?topic=optimization-example
WITH RECURSIVE cte_name AS (
cte_query_definition (the anchor member)
UNION ALL
cte_query_definition (the recursive member)
)
SELECT *
FROM cte_name;