Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
remove duplicated rows
--delete duplicate rows via cte row_number() -- https://rextester.com/QWMT21113 /*ROW_NUMBER() OVER ( [PARTITION BY partition_expression, ... ] ORDER BY sort_expression [ASC | DESC], ... ) */ create table test ([c1] varchar(5), [c2] int,[c3] int,[c4] int,[c5] int,[c6] int,[c7] int ); INSERT INTO test ([c1], [c2], [c3], [c4], [c5], [c6], [c7]) VALUES ('john', 1, 1, 1, 1, 1, 1), ('john', 1, 1, 1, 1, 1, 1), ('sally', 2, 2, 2, 2, 2, 2), ('sally', 2, 2, 2, 2, 2, 2), ('john', 1, 2, 2, 2, 2, 2), ('sally', 2, 2, 2, 3, 2, 2); SELECT * FROM dbo.test; with removedup as( select c1, c2,c3,c4,c5,c6,c7, rowno = row_number() over(partition by c1,c2,c3,c4,c5,c6,c7 order by c1) from dbo.test ) delete from removedup where rowno >1 select * from test;
run
|
edit
|
history
|
help
0
Delete double entries from a table without primary key
string splitter
ankit
UNPIVOT
Exa
gdfgfd
MyWall
MSQL in 10 mn ~ Lesson 9 Performing Mathematical Calculations - orderitems ~ expanded_price
2021-03-08_LeetCodeSQL
ERROR