我正在尝试将表中的某些数据插入到空表中,这就是我走了多远:
INSERT INTO T_TLF_KØ_KVARTER (TIDSPUNKT AS DATO,
TIDSRUM AS INTERVAL,
QUEUE AS KØ,
SUM(TOTAL_KALD_IALT) AS KALD_I_ALT,
SUM(ANTAL_KALD) AS KALD_INDGÅENDE,
SUM(ANTAL_DISTRIBUERET_KALD) AS KALD_DISTRIBUEREDE,
SUM(ANTAL_BESVARET) AS KALD_BESVAREDE,
SUM(IKKE_BESVARET_KALD) AS KALD_UBESVAREDE,
SUM(ANTAL_TABTE_KALD) AS KALD_TABTE,
SUM(BESVARET_25_SEK) AS KALD_BESVARET_U25,
SUM(CALLBACK) AS KALD_CALLBACKS,
SUM(BESVARET_I_KS) AS KALD_BESVARET_SC,
SUM(BESVARET_I_SC) AS KALD_BESVARET_DI,
SUM(BESVARET_PRI_SKILL) AS KALD_BESVARET_PRIMÆR_SKILL,
SUM(BESVARET_SEC_SKILL) AS KALD_BESVARET_SEKUNDÆR_SKILL)
FROM
GENESYS.NYK_SEAGATE_INTERVAL_QUEUE
GROUP BY
TIDSPUNKT,
TIDSRUM,
QUEUE
ORDER BY
QUEUE,
TIDSRUM
编辑:使用SELECT
INSERT INTO T_TLF_KØ_KVARTER (TIDSPUNKT AS DATO,
TIDSRUM AS INTERVAL,
QUEUE AS KØ,
SUM(TOTAL_KALD_IALT) AS KALD_I_ALT,
SUM(ANTAL_KALD) AS KALD_INDGÅENDE,
SUM(ANTAL_DISTRIBUERET_KALD) AS KALD_DISTRIBUEREDE,
SUM(ANTAL_BESVARET) AS KALD_BESVAREDE,
SUM(IKKE_BESVARET_KALD) AS KALD_UBESVAREDE,
SUM(ANTAL_TABTE_KALD) AS KALD_TABTE,
SUM(BESVARET_25_SEK) AS KALD_BESVARET_U25,
SUM(CALLBACK) AS KALD_CALLBACKS,
SUM(BESVARET_I_KS) AS KALD_BESVARET_SC,
SUM(BESVARET_I_SC) AS KALD_BESVARET_DI,
SUM(BESVARET_PRI_SKILL) AS KALD_BESVARET_PRIMÆR_SKILL,
SUM(BESVARET_SEC_SKILL) AS KALD_BESVARET_SEKUNDÆR_SKILL)
FROM
GENESYS.NYK_SEAGATE_INTERVAL_QUEUE
GROUP BY
TIDSPUNKT,
TIDSRUM,
QUEUE
ORDER BY
QUEUE,
TIDSRUM
SELECT
TIDSPUNKT AS DATO,
TIDSRUM AS INTERVAL,
QUEUE AS KØ,
SUM(TOTAL_KALD_IALT) AS KALD_I_ALT,
SUM(ANTAL_KALD) AS KALD_INDGÅENDE,
SUM(ANTAL_DISTRIBUERET_KALD) AS KALD_DISTRIBUEREDE,
SUM(ANTAL_BESVARET) AS KALD_BESVAREDE,
SUM(IKKE_BESVARET_KALD) AS KALD_UBESVAREDE,
SUM(ANTAL_TABTE_KALD) AS KALD_TABTE,
SUM(BESVARET_25_SEK) AS KALD_BESVARET_U25,
SUM(CALLBACK) AS KALD_CALLBACKS,
SUM(BESVARET_I_KS) AS KALD_BESVARET_SC,
SUM(BESVARET_I_SC) AS KALD_BESVARET_DI,
SUM(BESVARET_PRI_SKILL) AS KALD_BESVARET_PRIMÆR_SKILL,
SUM(BESVARET_SEC_SKILL) AS KALD_BESVARET_SEKUNDÆR_SKILL
FROM
GENESYS.NYK_SEAGATE_INTERVAL_QUEUE
GROUP BY
TIDSPUNKT,
TIDSRUM,
QUEUE
ORDER BY
QUEUE,
TIDSRUM
答案 0 :(得分:0)
正确的语法是
INSERT INTO destination_table (col1,col2--coln)
SELECT col1,col2---coln FROM source_table
WHERE condition; --if any
但是您正在使用聚合(SUM(TOTAL_KALD_IALT) AS KALD_I_ALT
)代替查询中的列名
答案 1 :(得分:0)
INSERT INTO T_TLF_KØ_KVARTER (DATO,
INTERVAL,
KØ,
KALD_I_ALT,
KALD_INDGÅENDE,
KALD_DISTRIBUEREDE,
KALD_BESVAREDE,
KALD_UBESVAREDE,
KALD_TABTE,
KALD_BESVARET_U25,
KALD_CALLBACKS,
KALD_BESVARET_SC,
KALD_BESVARET_DI,
KALD_BESVARET_PRIMÆR_SKILL,
KALD_BESVARET_SEKUNDÆR_SKILL)
SELECT
TIDSPUNKT,
TIDSRUM,
QUEUE,
SUM(TOTAL_KALD_IALT),
SUM(ANTAL_KALD),
SUM(ANTAL_DISTRIBUERET_KALD),
SUM(ANTAL_BESVARET),
SUM(IKKE_BESVARET_KALD),
SUM(ANTAL_TABTE_KALD),
SUM(BESVARET_25_SEK),
SUM(CALLBACK),
SUM(BESVARET_I_KS),
SUM(BESVARET_I_SC),
SUM(BESVARET_PRI_SKILL),
SUM(BESVARET_SEC_SKILL)
FROM
GENESYS.NYK_SEAGATE_INTERVAL_QUEUE
GROUP BY
TIDSPUNKT,
TIDSRUM,
QUEUE