sql - removing duplicate values in column -


there column called r_no 3 duplicate values associated date column

r_no         date values 1            09-apr-2016  03:49:24 1            09-apr-2016 03:49:30  1            09-apr-2016 03:49:40  

i want output as:

1 09-apr-2016 03:49:40 

removing duplicate values latest date value

use show :

select top 1 id, date #temp order date desc 

delete & show latest :

;with ttt (  select row_number() over(partition id order id)sr, date, id #temp )   delete  ttt date not in(select max(date) ttt)  select * #temp 

explanation: cte grab of records , apply row number each unique entry. each additional entry incrementing number.


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -