我正在尝试制作一个特定列出现两次的文件副本。我需要两个条目,但在一个单独的文件中。 下面附有编写的代码,但它无法读取需要子集的ID列表
CREATE TABLE DUPLICATECLIENTID_AVOX AS SELECT * FROM nodup_avox_data_v1_nr WHERE CLIENT_ID =(select client_id from (select CLIENT_ID, count(CLIENT_ID) as clientcount
from nodup_avox_data_v1_nr
group by CLIENT_ID
having count(CLIENT_ID) > 1));
答案 0 :(得分:1)
也许尝试使用IN(),如下所示:
CREATE TABLE DUPLICATECLIENTID_AVOX AS
SELECT *
FROM nodup_avox_data_v1_nr
WHERE CLIENT_ID IN (
SELECT CLIENT_ID
FROM nodup_avox_data_v1_nr
GROUP BY CLIENT_ID
HAVING count(CLIENT_ID) > 1
);
答案 1 :(得分:0)
试试这个:
CREATE TABLE DUPLICATECLIENTID_AVOX
AS
SELECT *
FROM nodup_avox_data_v1_nr
WHERE CLIENT_ID IN (SELECT CLIENT_ID
FROM nodup_avox_data_v1_nr
GROUP BY CLIENT_ID
HAVING COUNT(*) = 2
)
请注意我写了HAVING COUNT(*) = 2
,因为您希望列显示两次