Experts Exchange connects you with the people and services you need so you can get back to work.
;with cte as (
SELECT id, client, ROW_NUMBER() OVER (PARTITION BY id, client ORDER BY [date]) as row_number
DELETE FROM cte WHERE row_number > 1
Open in new window
DELETE FROM table
WHERE id = 1 AND date NOT IN (SELECT TOP 1 date FROM table WHERE id = 1 ORDER BY date)
Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.
(...)let the one row where date is lesser.
DELETE FROM tableName
WHERE date < (SELECT MAX(t2.date)
FROM tableName t2
WHERE tableName.idclie = t2.idclie)
CREATE TABLE testDeleet
INSERT INTO testDeleet VALUES
(1 ,'Alexander Garcia' , '05/10/2016'),
(1 ,'Alexander Garcia' , '03/10/2016'),
(1 ,'Alexander Garcia' , '01/21/2016')
FROM testDeleet j
WHERE j.Dt <> ANY
SELECT TOP 1 Dt a
FROM testDeleet e
WHERE e.ID = j.ID
ORDER BY e.Dt ASC
< Frasier Crane > When you know the answer it's hard not to hit the buzzer.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.