SELECT
B.CE_ID,
A.PPL_CNTR_ID,
SUM ( A.NBR_IN ) ENTERS,
SUM ( A.NBR_OUT ) EXITS,
A.LOG_TS
+ DECODE ( TO_CHAR ( A.LOG_TS,
'mi' ),
'05', 55
/ 1440,
'10', 50
/ 1440,
'15', 45
/ 1440,
'20', 40
/ 1440,
'25', 35
/ 1440,
'30', 30
/ 1440,
'35', 25
/ 1440,
'40', 20
/ 1440,
'45', 15
/ 1440,
'50', 10
/ 1440,
'55', 5
/ 1440,
0 )
TS
FROM
OUTPUTDB.TPPL_CNTR_TRAFFIC A,
FLUX.V_CE_PPLCNTR B
WHERE
A.LOG_TS BETWEEN '07-Sep-13' AND '08-Sep-13'
AND A.PPL_CNTR_ID = B.PPL_CNTR_ID
AND B.CE_ID IN (SELECT
DISTINCT CE_DPN_ID
FROM
TCE_RLT
START WITH
CE_PRN_ID = 5798
CONNECT BY
PRIOR CE_DPN_ID = CE_PRN_ID)
GROUP BY
B.CE_ID,
A.PPL_CNTR_ID,
A.LOG_TS
+ DECODE ( TO_CHAR ( A.LOG_TS,
'mi' ),
'05', 55
/ 1440,
'10', 50
/ 1440,
'15', 45
/ 1440,
'20', 40
/ 1440,
'25', 35
/ 1440,
'30', 30
/ 1440,
'35', 25
/ 1440,
'40', 20
/ 1440,
'45', 15
/ 1440,
'50', 10
/ 1440,
'55', 5
/ 1440,
0 )
ORDER BY
B.CE_ID,
A.PPL_CNTR_ID,
A.LOG_TS
+ DECODE ( TO_CHAR ( A.LOG_TS,
'mi' ),
'05', 55
/ 1440,
'10', 50
/ 1440,
'15', 45
/ 1440,
'20', 40
/ 1440,
'25', 35
/ 1440,
'30', 30
/ 1440,
'35', 25
/ 1440,
'40', 20
/ 1440,
'45', 15
/ 1440,
'50', 10
/ 1440,
'55', 5
/ 1440,
0 )
内部子查询
SELECT
DISTINCT CE_DPN_ID
FROM
TCE_RLT
START WITH
CE_PRN_ID = 5798
CONNECT BY
PRIOR CE_DPN_ID = CE_PRN_ID
返回 970 行,但是执行时间很长,请建议任何备用子句或加入,以便它运行得更快。使用的 2 个表只有一列共有,所以我很确定没有发生交叉连接。