Why does Rank() have gaps and Dense_Rank() not have gaps in ranking ties in rows?

Then encircled rows in the Rank / Dense_Rank examples below have ties for TotCnt.  Ex1 (using Rank()) has ties for TotCnt=19 and TotCnt=20.  Then TopCustomers rank jumps from 4 to 6.  In Ex2 (using Dense_Rank() for same set) has the same ties
but the TopCustomers rank goes smoothly from 4 to 5 and so on incrementing by 1.  Why is this?  What is different from Rank() vs Dense_Rank()? 
Use Northwind
SELECT RANK() OVER (ORDER BY TotCnt DESC) AS TopCustomers, CustomerID, TotCnt
FROM (SELECT CustomerID, COUNT(*) AS TotCnt
FROM Orders Group BY CustomerID) AS Cust
SELECT DENSE_RANK() OVER (ORDER BY TotCnt DESC) AS TopCustomers, CustomerID, TotCnt
FROM (SELECT CustomerID, COUNT(*) AS TotCnt
FROM Orders Group BY CustomerID) AS Cust
Rich P

DENSE_RANK() "Returns the rank
of rows within the partition of a result set, without any gaps in the ranking. The rank of a row is one plus the number of distinct ranks that come before the row in question."
Basically, DENSE_RANK() counts the number of distinct ranks prior to the current one, and adds one to it to determine the new rank. 
https://msdn.microsoft.com/en-us/library/ms173825(v=sql.110).aspx
RANK() "Returns the rank of each row within the partition of a result set. The rank of a row is one plus the number of ranks that
come before the row in question."
Basically, RANK() counts the number of ALL ranks prior to the current one, and adds one to it to determine the new rank.
https://msdn.microsoft.com/en-us/library/ms176102(v=sql.110).aspx
That difference is the reason for the two functions.
Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.

Similar Messages

  • Why does streaming video freeze and Internet not allow me to search Web when I airplay content from my MacBook Pro?

    I just bought Apple TV and my internet connection seems to cut out. I can't browse the internet once this happens? Once I unplug Apple TV and refresh router I get it back. What can I do to resolve this problem?

    I am having the same problem.  The MacBook Pro does not come with a startup disk so how can I get into the computer to begin anything?

  • Why does my new ipad and iphone not connecting to my server when my laptop and xbox do HELP

    NOT CONECTING TO INTERNET

    Did you mean router?
    We need information to do any kind of meaningful troublesghooting.
    Merely shouting (all caps on Internet means shouting)at us it's not working does nothing.

  • Why does my grandson's iPhone 5 not have the "None" option in his billing info and my iPad mini does.  We both live in Canada.

    Why does my grandson's iPhone 5 not have the "None" option in billing info?  I have it on my iPad Mini and on my iPhone 4S.  We both live in Canada within 20 minutes of each other.
    I bought him $30.00 worth of iTunes gift cards, he loaded them, but it won't let him use them.  It just goes to his previously entered Visa card which he no longer has and it won't let him unselect it either.  Sounds like theft to me!

    Because you that's not a supported bluetooth profile on the iPhone... In order to sync contacts with a handsfree system, the system needs to support the PBAP bluetooth profile. If it does, then the contacts will sync automatically.

  • HT1338 Why can't I update my iPad iso 4.2 version? I go to setting and it does not have it like it should. Why does apple have to make things so freaking hard! Help!

    Why can't I update my iPad iso 4.2 version? I go to setting and it does not have it like it should. Why does apple have to make things so freaking hard! Help!

    If you have an original iPad 1, the latest version of iOS it can run is iOS 5. So you should be able to update no problem.
    Update iTunes to the latest version (11.0.2). Then simply plug your iPad into the computer and open iTunes. Click the iPad either in the sidebar or the top navigation bar. Then attempt to update the software. If it doesn't work, please post the exact error message.
    Note that it would be wise to first ensure you back up the iPad.

  • Why does Adobe sendnow work and the newest and greatest Adobe Send does not work?

    Why does Adobe sendnow work and the newest and greatest Adobe Send does not work? I wasted about 8 hours on trying to get Adobe Send to upload 269 files that amounted to 469MB. When it did not work I made a zip file and after a lot of wasted run time that did not work. The first situation gives little indication of when a file is loaded compared to Adobe SendNow. In both cases with Send it failed with a message like only the first 50 can be loaded. When I went and looked none of them had been loaded. With the zip file (I wanted to hide the individual files so they would not be counted) it appeared to work but very slowly and finally said it was done and I went and looked and it had done anything for oever 2 hours except a false "I'm runninng" indication.
    Thus, I took a chance with Adobe SendNow and it works great. It never gave me a limit on the amount of files nor on the size of the complete job. It shows me one file at a time when it has finished with the file uploading it. SendNow has never given me any problems.
    Why woiuld you want to change the program from SendNow to Send without the newest program being the best, fastest, user friendly program of the two? It just doesn't make sense to me. I suggest that Adobe keep SendNow working until Send is fixed. I would also suggest that SendNow and how it looks be kept, called Send, then modify Send one thing at a time until you get it to the point you need it to be for Acrobat. I have heard nothing good and now I have experienced it that Send is a piece of junk. I wasted most of my work day on giving Adobe the benefit of the doubt to find out I made a very bad decision to trust Adobe to make good decisions on the transfer of a function to another place .... both Adobe's responsibility.without making it painless for your customers that totally rely on you. Don't throw away customer confidence as it is very hard to get it back.

    Funny how you answer to "troll". (What's your handle on AT&T forums?)
    Yep! Verizon living up to it's contractual obligations by not releasing updates. Caveat emptor!
    I think there are some reasonable expectations here to keep customer's happy. When one carrier offers upgrades there is an expectation the same will happen across all the carriers. We have seen that except Big Red.
    Verizon could have said the update is in MS court months ago and stilled the voice of the disgruntled, or at least redirected it, but instead chose to be silent. Not for market share but for partial blame I think.
    We will have to agree to disagree since you only see Terms & Conditions and I, see customer satisfaction.

  • Why does Firefox have to make it so difficult to get answers--I am not going to be able to check the website to see what anyone might reply to my question on crashing?

    I have no way of checking to see if anyone answers this. Why does Firefox have to make it so difficult?
    What does this means: DLL C:\Program Files\Mozilla Firefox\MOZCRT19.dll is not a valid Windows image. Please check this against your installation diskette.
    Suddenly all my tabs closed. Then Windows told me I had a gazillion infections. Then a tiny strip appeared saying it was Firefox and these little blocks started to fill up the little strip as if it were downloading something--there was no way to cancel this so I cut the power. Now when I try to use the Firefox icon, I get the message above.
    Am I supposed to remove the old Firefox stuff and start from scratch? I am stuck using Internet Explorer.
    I went to the Firefox website and tried to download it again, but McAffee jumped in and said there is something wrong with Firefox and I should register with them that I am downloading Firefox (I do not have McAffee). Then I got a security warning saying Firefox is not safe.
    I am completely at a loss as to what to do next, since I don't understand any of this mumbojumbo.

    Here's the story on one of your infections, namely JS:Redirector-EH[Trj]: http://www.microsoft.com/security/portal/Threat/Encyclopedia/Entry.aspx?Name=Trojan%3aJS%2fRedirector.H
    The main problem with malware is that it uses the installation to proliferate by contacting hostile servers to download more of the same rogue code.
    Firefox doesn't have the option to "Run" a file. You can only "Save File" or "Cancel". If you downloaded it with IE8, then yes, you can run it, but that's not what I wanted you to do.
    What you should do now is to disable System Restore. You can open System Properties by hitting the Windows logo key and Pause/Break key together. Then click the "System Restore" tab. Then checkmark the box which says "''Turn off System Restore on all drives''". Reboot to clear its contents. System Restore unfortunately makes a backup of all executables which includes viruses so that when you reboot without deleting them first, System Restore reinstates them again.
    After you complete that step, run Avast and Malwarebytes again to make sure the system is clean.
    Then go to the Windows Update site (link on your start menu) and install the missing patches which enabled your machine to become infected in the first place.
    Once the system is clean, repeat step one to download Firefox again, but please do not run the file. If you don't see the option to "Save File", cancel the download, but it should be there. You can use this direct download link to download FF4.0.1 [http://www.mozilla.com/products/download.html?product=firefox-4.0.1&os=win&lang=en-US Download Firefox 4.0.1]
    Run the file after you download it to the desktop.

  • Why does adobe photoshop elements 6.0 not show up for a download choice of putting my photos into my computer, I'm on windows7.  I'm sure it did when I first got my computer.  Could it be that I have lots of other photo software that may be interfering?

    why does adobe photoshop elements 6.0 not show up for a download choice of putting my photos into my computer, I'm on windows7.  I'm sure it did when I first got my computer.  Could it be that I have lots of other photo software that may be interfering?@@

    If you open the Organizer and go to Edit>Preferences>Camera or Card Reader, do you have Auto Launch Adobe Photo Downloader on Device Connect checked?
    Try checking that if you don't.

  • Why does my 7.0 iDVD theme not have sound playing in the menu?

    Why does my 7.0 iDVD theme not have sound playing in the menu?  When I click to get menu info, the "TravelAudio" audio is listed, but it won't play.  The volume is not the issue, it just isn't there. 

    Hi
    First of all - I would try to trash the iDVD pref file (or rather start a new User-account and log into this and re-try).
    Yours Bengt W

  • Why does windows have 64-bit iTunes but not mac?

    I can't believe it. I searched the archives here and someone said because most people don't have 64-bit compatible machines. Then why does Windows get separate versions but not the native OS?
    I'm running audio hardware optimized for 64-bit (drivers) but the sound quality of iTunes is worse in 64-bit than in 32-bit.
    Anyone have any knowledge when 64-bit is going to be released?

    iTunes is only 32 bit for Windows OS and Mac OS.
    The 64bit version for Windows simply includes 64 bit drivers. The application itself is only 32 bit.

  • My iMac locks up constantly in email. I click on one or two emails. Then when I click on another email, I get the spinning wheel and have to relaunch. Why does it get confused and lock up?

    My iMac locks up constantly in email. I click on one or two emails. Then when I click on another email, I get the spinning wheel and have to relaunch. Why does it get confused and lock up? Seems like it is stuck.

    10.6.8 here, MacBook Pro. Comcast. Mail  freeze ups. Occasional warnings to use "Log Out" under the Apple icon.
    Disk Repair run several times. Shows lots of Java  "remote" issues.
    I run Disk Repair several times, shows a lot of Java, "remote" issues.
    Restart don't know if it helps, I do it all the time. What's with quitting Mail but it doesn't quit, and why a separate maneuver to "Log Out".
    i

  • Does ISO5 support AirPrint and if not why did they do away with it?

    Does ISO5 support airprint and if not why did it disappear after ISO4? And will it be added back?

    It has gone nowhere.  Nothing has changed in regard to airprint.

  • Why does the type tool and note tool close my InDesign program? [was: InDesign CC technical]

    Why does the type tool and note tool close my InDesign program?

    Install the CC Desktop app, or try Help > Updates....
    If all else fails, you can try Crash | Launch, selecting Type tool, but there are other bug fixes in the update.

  • My sister has an iPad with iOS 6.1.3 and I have an iPod with iOS 6.1.3 why does she have Siri and I don't?

    My sister has an iPad with iOS 6.1.3 and I have an iPod with iOS 6.1.3 also why does she have Siri and I don't?

    Siri requires a 5th generation iPod Touch. Yours appears to be a 4th generation.

  • In formcentral, why does the "proceed to checkout" button not work? on IE I get error " This content cannot be displayed in a frame...

    In formcentral, why does the "proceed to checkout" button not work? on IE I get error " This content cannot be displayed in a frame. To help protect the security of information you enter into this website, the publisher of this content does not allow it to be displayed in a frame ". On Chrome I get nothing but loading.

    Hi,
     This error is generally specific to Internet Explorer and has two possible causes. The most likely explanation is that your browser has unusual browser security settings. I would recommend you try
    resetting your security settings to defaults (varies by version but all essentially the same). You may also have to turn off
    Protected Mode which is enabled by default on some systems. If you’re seeing this error (or a version of it) outside Internet Explorer, you may have a server-level setting that is preventing your content from being framed.
    Reference:https://social.technet.microsoft.com/Forums/exchange/en-US/1460c5a5-6242-4402-9f6b-bc581bf56478/content-cannot-be-displayed-in-a-frame-when-trying-to-add-item?forum=sharepointgeneral
    Thanks,
    Eric
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Eric Tao
    TechNet Community Support

  • Why does it have to be tethered???

    Hi, So I'm just about ready to buy the ipad. But I am having a big problem understanding WHY this thing cannot be used in my household, because my 2 apples run Tiger. If its a matter of an occasional update, I could take it to work to do that. I phoned the apple store, the rep said It can't work or sync without Leopard within my home wireless network. I also have within my wireless network 2.5 terabit of hard-drive and the rep was unsure if the ipad could see that either...
    Both of my computers are pre Intel processor, so I read that leopard & snow leopard are out of the question on my computers.
    If this is suppose the be the next big thing, Why does it have to be tethered to ANY computer. This IS sold as a wireless device, NOT an extension to another computer. Am I getting bad info or what.
    Please advise.

    Hi,
    All is not lost, I think. It's true that you'll need either Leopard or a Windows machine with the latest iTunes in order to get the iPad going. But you're right, you can just do that at work. The iPad will work perfectly after that without ever synching it again. You can do everything from the iTunes store from the iPad itself.
    However, if you want to synch your music not bought at iTunes, as well as iPhone apps and contacts then you're going to have to find a compatible computer to do it on. It needs the latest iTunes which doesn't run on Tiger. But once you've synched you don't really need to do it again unless you want to add a lot of music from another source than iTunes. Of course, synching also backs up the iPad, don't forget.
    As far as the gigundo drive, if the iPad doesn't recognize it, all you have to do is copy what you want synched to a smaller drive (or even a DVD) and use that instead.
    Hope that helps. The iPad is most definitely an independent device but it does need a compatible computer if you want to synch stuff to it from elsewhere.
    SP

Maybe you are looking for

  • How to connect to password protected wifi in hotels etc

    On my iPad the login page automatically pops up and I get access pretty easy. How does this work for Safari on my MacBookPro ? I struggle to get access

  • ITunes keeps unexpectedly quitting. Can't pinpoint issue.

    I can't find any definitive answers on here as there seem to be many causes for these crashes and nothing too recent. Either way, iTunes keeps 'unexpectedly quitting' everytime I start iTunes. The problem seemed to start after I synched with my Apple

  • HT1296 sync failed to start

    I have a collection of CDs which I ripped a year plus ago on my Laptop. Recently I started using iTunes to manage & play these Albums. I decided to copy/sync the files to my iPhone. I installed & enabled on the iPhone & it appears in iTunes under dev

  • Need help to fix my pc

    my computer is completely turned to window, all the apple system is deleted,while i download window xp now the computer is working as a window xp not as an apple. i try to download re-installation cd but i can;t.i need help if somebody guide me i wil

  • Unwanted "frame" bars on correctly-sized footage?

    I'm editing in Final Cut Studio 7 and even though my footage is the proper ratio (16:9) every time I render and play it back, it crunches it down to include black bars at the top and bottom. I've never used Final Cut for a 16:9 video before, as I was