我想通过以下查询删除所有记录 return
I want to delete all the records return by below query
我想使用 delete 而不是 select 子句(雪花)。
WITH duplicates as(
select row_number()over(partition by ASCII,keyt,prodt,counter,batch_id ,batch_time,overall_level,is_f,is_s,is_c order
by batch_time DESC)as r,
* from temp_table
where batch_time BETWEEN '2021-12-01' and '2021-12-31')
select count(*) from duplicates as d where r>1 order by keyt;
根据您提供的查询,您似乎没有构成唯一键的列,因此一种选择如下。
--- 未测试
CREATE TABLE new_table LIKE temp_table ;
INSERT INTO new_table SELECT DISTINCT * FROM temp_table;
ALTER TABLE temp_table SWAP WITH new_table;
我想使用 delete 而不是 select 子句(雪花)。
WITH duplicates as(
select row_number()over(partition by ASCII,keyt,prodt,counter,batch_id ,batch_time,overall_level,is_f,is_s,is_c order
by batch_time DESC)as r,
* from temp_table
where batch_time BETWEEN '2021-12-01' and '2021-12-31')
select count(*) from duplicates as d where r>1 order by keyt;
根据您提供的查询,您似乎没有构成唯一键的列,因此一种选择如下。
--- 未测试
CREATE TABLE new_table LIKE temp_table ;
INSERT INTO new_table SELECT DISTINCT * FROM temp_table;
ALTER TABLE temp_table SWAP WITH new_table;