0
我正在將oracle查詢轉換爲maria db。在MariaDB中沒有分層查詢,如「開始......連接...」。所以我不得不創建類似於「以......開頭......」的查詢,但它看起來很難。你們能幫我嗎?將Oracle分層查詢轉換爲MariaDB
SELECT *
FROM
(SELECT T2.JOB_TYPE,
T2.COMPONENT_TYPE,
T1.POOL_SEQ,
FN_GET_CODE_VALUE('componenttype',T2.COMPONENT_TYPE) AS COMPONENT_TYPE_NM,
MIN(T1.WORKFLOW_SEQ)WORKFLOW_SEQ,
MIN(T1.UPPER_WORKFLOW_SEQ)UPPER_WORKFLOW_SEQ,
MAX(T1.DEFAULT_JOB_SEQ)DEFAULT_JOB_SEQ,
T1.WORKFLOW_TYPE,
/* MAX(T1.WORKFLOW_TYPE)WORKFLOW_TYPE, */
COUNT(CASE T1.JOB_STATE WHEN '01' THEN 1 END)STATE_01_CNT,
COUNT(CASE T1.JOB_STATE WHEN '02' THEN 1 END)STATE_02_CNT,
COUNT(CASE T1.JOB_STATE WHEN '03' THEN 1 END)STATE_03_CNT,
COUNT(CASE T1.JOB_RESULT WHEN '20' THEN 1 END)ERCNT,
COUNT(CASE T1.JOB_RESULT WHEN '10' THEN 1 END)END_CNT,
COUNT(*)TOT_CNT
/* ,MAX(T1.POOL_SEQ)POOL_SEQ */
FROM JOB_TBL T1,
SERVER_POOL_TBL T2
WHERE T1.POOL_SEQ = T2.POOL_SEQ
)T
START WITH UPPER_WORKFLOW_SEQ IS NULL
CONNECT BY UPPER_WORKFLOW_SEQ = PRIOR WORKFLOW_SEQ
我不認爲瑪麗亞DB有一個相當於'connect by' ..雖然你可以在一個過程或函數中實現它。 – GurV