Viewing 2 posts - 1 through 2 (of 2 total)
The following should work to bring back a single ID for each. Would recommend indexes on parentCode + internalReference and internalReference if not already present.
SELECT MIN(c.ID) AS ID,
...
May 23, 2014 at 9:45 am
#1716149
Have you tried the DENSE_RANK() function? It's called exactly the same way as ROW_NUMBER() and should sort your problem.
February 27, 2014 at 9:18 am
#1692752