我正在使用IBM工具“JRS”从DB2中“RTC”中提取数据。 我有下面的代码,它工作得很好:
SELECT
CASE WHEN (T3.REQUEST_TYPE = 'Corretiva' OR T3.REQUEST_TYPE = 'Corretiva Interna' )
THEN (MAX(T1.ACTUAL_WORK) - MIN(T1.ACTUAL_WORK))/3600
ELSE 0
END AS CORRETIVAS_TIME,
(MAX(T1.ACTUAL_WORK) - MIN(T1.ACTUAL_WORK))/3600 AS TOTAL_TIME
FROM RICALM.VW_RQST_HISTORY T1 -- HISTORICO DA TAREFA
INNER JOIN RICALM.VW_RQST_HISTORY T0 -- HISTORICO ANTERIOR DA TAREFA
ON T0.REQUEST_HISTORY_ID = T1.PREV_REQUEST_HISTORY_ID
INNER JOIN RIDW.VW_REQUEST T2 -- TAREFA
ON T2.REQUEST_ID = T1.REQUEST_ID
INNER JOIN RIDW.VW_REQUEST_RELATIONAL_LINK LT1
ON T2.REQUEST_ID = LT1.REQUEST1_ID AND LT1.NAME = 'com.ibm.team.workitem.linktype.parentworkitem'
INNER JOIN RIDW.VW_REQUEST T3 -- CORRETIVA
ON LT1.REQUEST2_ID = T3.REQUEST_ID AND LT1.NAME = 'com.ibm.team.workitem.linktype.parentworkitem'
WHERE ( YEAR(CURRENT_TIMESTAMP)*12 + MONTH(CURRENT_TIMESTAMP) = YEAR(T1.REC_DATETIME)*12 + MONTH(T1.REC_DATETIME)
)
AND T1.ACTUAL_WORK <> T0.ACTUAL_WORK
AND T2.REQUEST_TYPE = 'Tarefa'
AND (T3.REQUEST_CATEGORY_NAME = 'SIENGE/Manutenção Contínua/MC-COMCRC' OR
T3.REQUEST_CATEGORY_NAME = 'SIENGE/Manutenção Programada/MP-COMCRC')
AND
(T1.ISSOFTDELETED = 0 AND T2.ISSOFTDELETED = 0 AND T3.ISSOFTDELETED = 0)
GROUP BY T1.REFERENCE_ID,T3.REQUEST_TYPE
导致以下表格:
corretivas_time
total_time
0 0
0 6
0 0
0 6
0 0
1 1
4 4
现在我想得到每列的总和来比较彼此,所以我做了以下选择:
SELECT
SUM(CASE WHEN (T3.REQUEST_TYPE = 'Corretiva' OR T3.REQUEST_TYPE = 'Corretiva Interna' )
THEN (MAX(T1.ACTUAL_WORK) - MIN(T1.ACTUAL_WORK))/3600
ELSE 0
END) AS CORRETIVAS_TIME,
SUM((MAX(T1.ACTUAL_WORK) - MIN(T1.ACTUAL_WORK))/3600) AS TOTAL_TIME
剩下的就是一样......
我收到此错误:
CRRGW5628E com.ibm.db2.jcc.am.SqlSyntaxErrorException错误 验证由DB2 SQL引起的输入SQL字符串时发生 错误:SQLCODE = -112,SQLSTATE = 42607,SQLERRMC = SUM,DRIVER = 4.14.121。
我也试过这段代码:
SELECT SUM(SELECT
CASE WHEN (T3.REQUEST_TYPE = 'Corretiva' OR T3.REQUEST_TYPE = 'Corretiva Interna' )
THEN (MAX(T1.ACTUAL_WORK) - MIN(T1.ACTUAL_WORK))/3600
ELSE 0
END AS CORRETIVAS_TIME
其余的都是一样的。
我收到了这个错误:
CRRGW5628E com.foundationdb.sql.parser.SQLParserException错误 在验证由Encountered引起的输入SQL字符串时发生 “”在第2栏第12栏。期待以下之一:。
答案 0 :(得分:0)
我几乎可以肯定你想要这样的东西:
while COUNT < GENERATIONS:
for i in range(NP):
a, b, c = (i, i, i)
while i in (a, b, c):
a, b, c = random.sample(xrange(NP), 3)