Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
抓住的是,整行都是一样的。
桌子:
Hello Hello Hello Bye Bye Good Morning Good Morning
我想离开:
Hello Bye Good Morning
我知道你可以在这里使用 RANK() 但我从未真正使用过它,所以我不太确定。
谁能帮我一把?
您可以使用row_number()然后从表中删除行号不为 1 的所有内容:
row_number()
;with cte as ( select col, row_number() over(partition by col order by col) rn from yourtable ) delete from cte where rn > 1;
请参阅带有演示的 SQL Fiddle