June 24, 2009 at 4:47 am
Hi All,
Can guyz tell me, why DISTINCT is not working in this context. How can it will be possible in the ROW_NUMBER().
DECLARE @test-2 TABLE (fldCID varchar(8))
INSERT INTO @test-2 (fldCID)
SELECT '1.1' UNION ALL
SELECT '1.1' UNION ALL
SELECT '1.1' UNION ALL
SELECT '2.2' UNION ALL
SELECT '2.2' UNION ALL
SELECT '2.2' UNION ALL
SELECT '3.3' UNION ALL
SELECT '3.3' UNION ALL
SELECT '3.3' UNION ALL
SELECT '4.4' UNION ALL
SELECT '4.4' UNION ALL
SELECT '4.4'
SELECT DISTINCT
ROW_NUMBER() OVER (ORDER BY fldCID),
fldCID
FROM @test-2
---
June 24, 2009 at 5:01 am
I think ROW_NUMBER is the wrong function in this case. Try RANK or DENSE_RANK:
SELECT DISTINCT
DENSE_RANK() OVER (ORDER BY fldCID),
fldCID
FROM @test-2
How to Post Data/Code to get the best Help How to Post Performance Problems
June 24, 2009 at 5:12 am
Thanks guyz for your reply.
June 24, 2009 at 5:14 am
Glad we could help
How to Post Data/Code to get the best Help How to Post Performance Problems
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply