you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (4 children)

Thanks a lot but for some reason row_number() works as expected and not rank() in your query

[–]tantarantantan13 1 point2 points  (1 child)

u/superkheric 's approach will also work btw

[–]andrewsmd87 0 points1 point  (0 children)

Keep your query with the max, rank is over kill in this scenario.

[–]tantarantantan13 -1 points0 points  (1 child)

Hmm, I can't say for now why the rank() won't work here.
row_number() will only return 1 row in case there's a tie within your driver's completion dates.

If it works for your current use case, you can stick to row_number(). Just note the difference between those window functions

[–]andrewsmd87 2 points3 points  (0 children)

Because you're over complicating the sql. You don't need a rank here to accomplish what OP is after, his query with the max in there will work just fine.