Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Delete double entries from a table without primary key
create table tbl (id int, lastprice float, updatetime time, updatems int); insert into tbl VALUES (211709,51370.,'09:30:00',0), (211709,51370.,'09:30:01',0),(211709,51370.,'09:30:01',500), (211709,51370.,'09:30:02',0),(211709,51370.,'09:30:02',0),(211709,51370.,'09:30:03',0),(211709,51370.,'09:30:04',0), (211709,51370.,'09:30:04',300),(211709,51370.,'09:30:04',300); SELECT * from tbl; DELETE seq FROM (SELECT ROW_NUMBER() OVER(PARTITION BY id, updatetime ORDER BY id, updatetime, updatems ASC) AS RowNum FROM tbl ) seq where rownum>1; SELECT * FROM tbl
run
|
edit
|
history
|
help
0
c12part2
tesing
FORMAT FUNCTION (New Feature of 2012 sql server)
Co-Related sub query
Create Date list (variable dates) - SQL Server
RBT QA
Lab assessment 2
repert
table emp
Basic Template