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
Mahi
Pro 2
SQL for beginners( defined with errors while enforcing constraints)
sql server dynamic 12 month time series and pivot with month year column names
Finding Duplicate Rows in sql
STACK
GKM_JOIN
product_sales
Insert With Output Cluase
Factorial