Teradata SQL Query可以自动增量吗?
我正在寻找类似于
的东西SELECT
Date (Auto-Increment by 1 over Column 2),
Column 2,
Column 3
FROM Fake_Table
GROUP BY 1,2,3
获得诸如
之类的东西Date Column 2 Column 3
2012-06-11 A A
2012-06-11 A B
2012-06-11 A C
2012-06-12 B A
2012-06-13 C B
这可能吗?
答案 0 :(得分:2)
您应该能够使用带有PARTITION BY和ORDER BY语句的ROW_NUMBER()窗口聚合来为您提供要添加到DATE的种子值。
伪码:
SELECT
CURRENT_DATE + ROW_NUMBER() OVER(PARTITION BY Column2,
ORDER BY Column2) AS MyDate
Column2,
Column3
FROM Fake_Table
GROUP BY 1,2,3