Hi,
The thing I ask is probably very basic but I don't really get the point.
I found this query in one of the posts and I do not understand a part of it.
;WITH CTE AS ( SELECT GroupID , Name , ROW_NUMBER() OVER(PARTITION BY GroupID ORDER BY (SELECT 0)) AS Ranking FROM YourTable ) SELECT GroupID , Name FROM CTE WHERE Ranking = 1
I understand that ROW_NUMBER() requires an order by clause, but what order does 'order by (select 0)' generate? Why is it 0? Can it be any other constant?
Thanks.
P.