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
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 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy