我们每天从 200 个交通站点获取数据,所有站点都有不同的表名,例如 (KGM_000000000001_PVR)。所有站点具有相同的列排序,具有相同的列名。我们总是会收到不同愿望的报告,我们将站点与联合全部结合起来,如下例所示。一直以来,我们将它们与 union all 结合起来,这有点困难。有没有其他简单的方法来获得类似报告(使用循环、案例、for 等)。
莱万特
谢谢
报告代码示例:
SELECT count(class) from C2.KGM_000000000001_PVR WHERE class=9 and RECTIME BETWEEN TO_DATE('01.01.2012','DD.MM.YYYY') AND TO_DATE('01.01.2013','DD.MM.YYYY')
union all
SELECT count(class) from C2.KGM_000000000002_PVR WHERE class=9 and RECTIME BETWEEN TO_DATE('01.01.2012','DD.MM.YYYY') AND TO_DATE('01.01.2013','DD.MM.YYYY')
union all
SELECT count(class) from C2.KGM_000000000003_PVR WHERE class=9 and RECTIME BETWEEN TO_DATE('01.01.2012','DD.MM.YYYY') AND TO_DATE('01.01.2013','DD.MM.YYYY')
union all
.
.
.
SELECT count(class) from C2.KGM_000000000200_PVR WHERE class=9 and RECTIME BETWEEN TO_DATE('01.01.2012','DD.MM.YYYY') AND TO_DATE('01.01.2013','DD.MM.YYYY')