I hope your looking for this
--Create sample data
CREATE TABLE Projects
([Project] varchar(1), [Version] int)
;
INSERT INTO Projects
([Project], [Version])
VALUES
('A', 1),
('A', 2),
('A', 3),
('A', 4),
('B', 1),
('B', 2),
('B', 3),
('C', 1),
('C', 2),
('D', 1)
;
WITH CTE AS(
SELECT *, Row_Number()OVER(Partition by Project Order by version desc) ROWNUM
FROM Projects)
SELECT * FROM CTE WHERE ROWNUM=1
Satheesh
My Blog | How to ask questions in technical forum
No comments:
Post a Comment