January 3, 2024 at 12:00 am
Comments posted to this topic are about the item SQL Window Functions Series: NTILE()
Nikhil Bangad
January 3, 2024 at 8:45 pm
I am slightly confused by the last example - Integrating NTILE with RANK(), DENSE_RANK(), LAG(), and LEAD(). You have both LAG and LEAD partitioned by EmployeeId and EmployeeID is unique in the result set YET you are getting values in those columns. I am confused how you got results in those columns when it looks to me like it shouldn't give any results.
Am I understanding things wrong and results in those columns are expected or am I reading it right and those columns should be NULL the whole way down? If they are expected, could someone explain to me why results should show up in those columns as I am really having a hard time figuring it out...
The above is all just my opinion on what you should do.
As with all advice you find on a random internet forum - you shouldn't blindly follow it. Always test on a test server to see if there is negative side effects before making changes to live!
I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.
January 4, 2024 at 3:25 pm
Just wanted to add, I liked the article. I wasn't trying to criticize it, especially since I've never had the guts to post one on here. I just wanted clarification on the last query as to me it looks like the results don't match the data/query. BUT I could easily be wrong on this too. Wouldn't be the first time I was wrong, and won't be the last :).
The above is all just my opinion on what you should do.
As with all advice you find on a random internet forum - you shouldn't blindly follow it. Always test on a test server to see if there is negative side effects before making changes to live!
I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.
January 4, 2024 at 4:25 pm
HI Brian,
Appreciate you catching it. The issue is the dataset in the example is not aligning correctly with the result set. I just copied a snap-shot of the example dataset, that is causing the confusion. I will try to update the dataset and the result set accordingly.
Thank you once again! It's good to know that folks are actually taking the time to go through the article in detail.
Nikhil Bangad
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply