Hive-SQL obtiene una lista de 1 ~ N números consecutivos (sin bucles, utilizando el producto cartesiano)

WITH Digits AS (
    SELECT 0 AS Number
    UNION SELECT 1
    UNION SELECT 2
    UNION SELECT 3
    UNION SELECT 4
    UNION SELECT 5
    UNION SELECT 6
    UNION SELECT 7
    UNION SELECT 8
    UNION SELECT 9
)

SELECT chapter FROM (
	SELECT
	      (d4.Number * 10000)
	    + (d3.Number * 1000)
	    + (d2.Number * 100)
	    + (d1.Number * 10)
	    + d0.Number AS chapter
	FROM
	      Digits AS d4
	    , Digits AS d3
	    , Digits AS d2
	    , Digits AS d1
	    , Digits AS d0
	) t1
WHERE chapter > 0 AND chapter <= 20000
GROUP BY chapter
ORDER BY chapter

Resultado de la operación: 1 ~ 20000

Supongo que te gusta

Origin blog.csdn.net/H_X_P_/article/details/108193539
Recomendado
Clasificación