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
Life cycle
emp 4
Select empID whose salary is greater than their managers
db
sql_fb
SQL_DS_collections
Check Constraints
create table with constraunt
Cine Latinoamericano
Library Datebase