Hi Experts,
Please can you let me know the order of processing of the window functions,
Select
t.TrackId, t.Name, t.AlbumId, T.MediaTypeId, t.GenreId, T.Composer, T.Milliseconds, T.UnitPrice
,DENSE_RANK() over( order by T.Milliseconds desc) As TrackDurationRank -- 1
,DENSE_RANK() over (Partition by t.AlbumId order by T.Milliseconds desc) as TrackdurationPerAlbum -- 2
FROM dbo.Track t;
--Order by T.AlbumId asc, T.Milliseconds desc
Go
Select
t.TrackId, t.Name, t.AlbumId, T.MediaTypeId, t.GenreId, T.Composer, T.Milliseconds, T.UnitPrice -- 1
,DENSE_RANK() over (Partition by t.AlbumId order by T.Milliseconds desc) as TrackdurationPerAlbum --2
,DENSE_RANK() over( order by T.Milliseconds desc) As TrackDurationRank
FROM dbo.Track t;
--Order by T.AlbumId asc, T.Milliseconds desc
Go
Thanks a lot for help
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
March 26, 2022 at 9:57 pm
It's real simple... Group By does not guarantee the order of the output, period. Only an ORDER BY will make that guarantee.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply