HR Schema: Select salary which is earned by the most employees+how often

hi all,
select * from (
SELECT salary, COUNT(salary)
FROM employees
group by salary order by 2 desc) where rownum < 2;
SALARY | COUNT(SALARY)
2500 | 6
Is there another solution for this result (without rownum)?
thanks

user13428495 wrote:
thanks a lotYour solution was way better then all others posted so far. Why? Because you only scanned the employees table one time. All others needed to scan this table two times. Therefore your query will probably execute faster if the data will become more. For small data sets you will not notice any difference.
Other solutions that will only scan the table one time can be using the KEEP syntax or an analytic function.
untested
/* aggregate version */
select max(count_sal), max(salary) keep (dense_rank first order by count_emps desc)
from (SELECT salary, COUNT(*) as count_emps
        FROM employees
       group by salary )
/* maybe the double group works directly without extra select */
select max(COUNT(*)) cnt, max(salary) keep (dense_rank first order by COUNT(*) desc) salary
FROM employees
group by salary;
/* analytic version with a different output*/
select v2.* from (
   select v1.*, rank() over (order by count_emps desc)
   from (
      SELECT e.*, count(*) over (partition by e.salary) count_emps rn
      FROM employees e) v1
   order by count_emps desc) v2
where v2.rn = 1Edited by: Sven W. on Sep 8, 2011 1:53 PM typo correction: dense_rank

Similar Messages

  • Since purchasing the Note 3 in October i have had nothing but issues. I went through all the steps and eventually I was sent a different phone, which was working for the most part until the recent upgrade. Now I am back to the old issues, no service, it a

    Since purchasing the Note 3 in October i have had nothing but issues. I went through all the steps and eventually I was sent a different phone, which was working for the most part until the recent upgrade. Now I am back to the old issues, no service, it actually says not moblie network available, when everyone else in my family has coverage and are on my plan with iphones. I am missing text messages and dropping calls left and right. This is unacceptable for the cost of this phone and my service. I have did a hard reset etc. What else can I do??

    Use the trackpad to scroll, thats what it was designed for. The scroll bars automatically disappear when not being used and will appear if you scroll up or down using the trackpad.
    This is a user-to-user forum and most people will post on here if they have problems. You very rarely get people posting to say there update went smooth. The fact is the vast majority of Mountain Lion users will not be experiencing any major problems with the OS, or maybe with apps which are not compatible, but thats hardly Apple's fault if developers don't update their apps.

  • How can I find which applications are using the most power?

    I have recently noticed a full charge of power doesn't last as long as it used to on my iPad 2.  Is there some way to determine which applications are using the most power?
    I have been monitoring my home network router accesses and have noticed the iPad logs accesses every 15 seconds.  This only happened recently.  It had been well behaved and only accessing once or twice a day before.  I installed the most recent iTunes upgrade, per suggestions during a Sync.  The problems seemed to occur after this update.  I have gone through all the settings and have minimized the applications requiring higher power (I switch off the location services unless I'm away from home.  Likewise, I turn off my cellular carrier unless I'm away from home, etc.)
    In short, how can I maximize my power usage (aside from turning it off)?
    Thanks.
    Dave

    Thanks for responding so quickly.
    I'm really trying to find out why the battery is depleting much faster than it used to all of a sudden.  I used to be able to put a full charge on it and it would last about 5 to 6 days with normal use (normal for me).  Now that battery only lasts about 2 to 3 days with the same use.
    I DO recharge it when it needs to be charged but this is indicating there is something else (new) that is causing the power drain.

  • Which exercise learnd you the most?

    Hi,
    I would like to know good exercises to improve my programming. I'm a beginnier and the most advanced program I made is a pokergame where the user interact through command line, that means no Swing classes. I also know algorithms like recursion, polymorphism, inheritance and so on..
    Now hit me, what should be my next project? I would like to learn DB-modeling, I know nothing about that. I also want to learn more about I/O-streams in Java, for example, how you read data from the webb in to an application?
    But these are just topic-suggestions from me, if you have other exercises that you think is good I take them too..
    PS. I know google can help for exercises, but I want to know which one learnd YOU the most.
    Edited by: Ani_Skywalker on Jun 27, 2008 4:31 AM

    DrLaszloJamf wrote:
    My advice is not to rush into Swing or JSP/servlets. Learn more Java first. You mentioned I/O. What about the collections framework? XML processing? JDBC? Some frameworks the Hibernate and Spring? Design Patterns?Collection framework. No.
    XML. No.
    JDBC. Began to look at it this morning, after I opened this thread.
    Frameworks. Some Swing but I would say no.
    Design Patterns. Come cross this before, but no. I can't say that I know it...
    I'm gonna stick whit command line for the moment. I don't get to excited about GUI:s because I can put almost everything that I can code into a GUI, and the other way around. Therefore I think, just like some of you wrote, that I need to improve my Java. When I reach a level were I can't put my code in GUI:s, then I probably get excited about it...

  • But i'm worried about the audio quality which matters to me the most !! is the audio quality on iPod with ear-pods the same as iPad with earpods ?

    hi guys !! i'm an ipod touch 5g user ! and i want to switch to ipad !! but i'm worried about the audio quality which matters to me the most !! is the audio quality on iPod with ear-pods the same as iPad with earpods ?

    thnx i'm more satisfied now !

  • Any way to find out which apps I use the most?

    Sometimes there are apps that I don't realize I use a lot. Is there any way to find out which apps I use the most, so I can put those on my first home screen?

    I'd keep and eye on your multitask bar. This tells me what apps I use and often forget I've been in that day.

  • How to select on which server to run the restore job?

    Hello gurus!
    We run OSB 10.4.0.2.0 (Solaris)
    There are several media-servers in configuration one of them is temporaroly unavailable.
    When I issue a restore job on the admin server it tries to be execured on that media server which is unavailable, see the output of lsjob -l:
    admin/3:
    Type: restore 1 item
    Restore to host: istore
    Media file number: 198
    Volume: OSB-CATALOG-MF-000014
    Restore original path:
    To path: /tmp/111
    Scheduled time: none
    State: retryable at 2012/12/12.13:18 ("lsjob --log admin/3" for details)
    Priority: 100
    Privileged op: no
    Run on host: mxdb-fin-2
    Attempts: 0
    I was unable to find any option which may tell OSB to run on istore server. Could you suggest any?

    You could simply take the media server out of service which means OSB won't try to use it. When it is available again, you can put it back in service.
    Or, you could restrict the backup to specific media server and tape drives.
    Donna

  • I'm trying to download itunes onto an external harddrive, but it keeps defaulting to my computers drive which does not have the room. How do I sort this please?

    I'm trying to download itunes onto an external harddrive (named as D) which has loads of space, but it keeps defaulting to my computers (C) drive which does not have the required space. How do I sort this please?
    I've tried selecting the D drive but, it still defaults to my computers drive and wont let me change it.
    Heeeeellllllllpppppp!

    I think you've misunderstood.
    iTunes ONLY works on the C drive.  There is no moving it.  End of discussion.
    The MEDIA can be house on any other drive (internal or external).
    Install iTunes correctly using the default options.
    Once it is installed and working correctly with everything on the C drive, close iTunes.
    Follow the instructions here: http://support.apple.com/kb/HT1364 to move the iTunes media folder.

  • Somebody has created an apple id using my gmail id. So I gave forgot password option and reset the password of the id. But for resetting the security questions, link is going to some other email id which is created by the other guy.How can I resolve this?

    When I tried to create and apple id using my gmail account i found that somebody has already created an apple id using my gmail id. So I gave forgot password option and reset the password of the id. But for resetting the security questions, link is going to some other email id which is created by the other guy. Now the problem is that the other guy also can reset my password and access my account.
    I contacted apple customer care and they are not ready to help me saying that I need to give information about the last device I logged in using this id. How can I give it when I did not create it?:) Also they are saying this account has been verified and that could happen only if someone has hacked my gmail account and verified the id using the link sent by apple.
    Later I did some experiments and found that this is a security flaw from apple. Somebody has created the id and never used it(I tried to loggin to icloud and it was saying this account was not used it any apple device). The account became verified when I reset the password.(This is a bug, account should be verified only when we click on the verification link sent by apple).
    The other mistake apple did is that they allotted my gmail account to someone before it's verified eventhough it cannot be used unless verified. Actually apple should allot the account id only after verifying the email address.
    Apple customer care is not ready to help and I am tired of fighting with them. Can any of you guys suggest any means of getting back my gmail id to use it as apple id?

    I don't think you're going to be able to. I would guess the other person used your address by accident, and when he found he couldn't access the account (because you'd changed the password) he abandoned it. Your GMail address is now locked to that account and even if it was changed you can't use it to create another.
    You already have an Apple ID, which you use to log in here; you can use that to create an iCloud account if that's what you are trying to do. If you want to create a different Apple ID just get another free address such as a Yahoo one.

  • How to find out which session is consuming the most of sga

    Hello,
    I have a server that is running out of swap space. I like to find out which oracle session is using a lot of the sga. Which data dictionary has this view? Thank you. 9208, linux 4.

    How did you configure SGA memory managment?
    How much real memory is available on the machine?
    How large did you make the SGA?
    How much PGA do you think you need?
    See Oracle version# Reference manual and start with
    v$process -- show pga per process and can be joined to v$session to identify front-end process
    v$pgastat
    v$sga
    v$sgastat
    HTH -- Mark D Powell --

  • HT1444 Upgrading from 10.5.8 to 10.6 (or later) which later version makes the most sense?

    For work-related remote-access using Citrix, I will need to upgrade from V10.5.8 to V10.6 (or a later version).  Which new version would make the most sense?

    Since it's a 10.5 era issued machine and rather dated, the best OS X version is 10.6.3 via the white retail disks, call Apple Sales by phone and order it for $29.
    10.6 will run your presently installed 10.5 software as 10.7 or 10.8 will not. Also 10.7 or 10.8 will slow your machine down to a crawl, so it doesn't make much sense to go there.
    Since your machine is getting long in the tooth, it's got not that much longer to go, I would be considering a newer 10.8 or 10.9 machine (next summer) and ease yourself into in.
    So 10.6 now, 10.8 or 10.9 on a new machine later.
    Don't upgrade to 10.8 and don't worry about it, over 50% of OS X users are on 10.6 currently, (30% on 10.7) and about 5% on 10.8 just released.
    Things to consider before upgrading OS X
    Back up only your personal info off the machine to a external storage drive (not TimeMachine!), disconnet it. Stick the 10.6.3 disk in and run the updater.
    Most commonly used backup methods
    If you need to wipe and install, (like if you have problems because your 10.5 is funkyed up)
    How to erase and install Snow Leopard 10.6
    Install your programs from fresh original sources and last hook up your storage drive and return files into same named accounts.

  • HT1386 my ipad will not sinc with my computer - it lists it but it has an additional computer listed in which it looks for the sinc option how do I get rid of the bogus computer

    When attempting to share music on Itunes with my IPad I receive a message telling me that my Ipad contents will be eraced if I attempt to sinc with this computer.  Under General settings it lists my computer and a bogus computer.  If I sinc it will I lose all the contents on my Ipad or only the music library which is empty?

    Does this apply?
    If you're asked for the password to your previous Apple ID when signing out of iCloud - Apple Support

  • Which webpage size is the "most normal" to use?

    Hey everyone out there.
    I'm creating a webpage in Muse. In the Plan-part of the program the page is shown just as I want it, but when I upload it on my browser it looks all wrong.
    It's like my page is too small for the browser, because big white gaps are shown in both the left and the right side. Besides, when I make my browser widescreen, there is also a gap between the footer and the bottom of the browser.
    Anyone out there who know what to do? Or if there is a size for the webpage which is best to use, so it is shown normally in the browser?
    My webpage currently has the size W:1220px H:768px

    Hi,
    Can you please share the Url of your website so that we can have a look and see what is the issue that you are facing.
    And regarding the size of the webpage , please refer to this link :- http://helpx.adobe.com/muse/topics/page-layout.html
    Hope this helps
    Regards,
    Rohit Nair

  • In the former version of iTunes there was an option by means of which I could see the most recent podcast even for those I did not subscribe to. Apparently, with 11.2 this option is gone. Any help?

    Hi folks,
    in former versions of iTunes I could update the list of available podcasts even for those I did not subscribe to.
    Where is this feature in iTunes 11.2?
    Help is appreciated!
    Regards
    Klaus

    well nobody bothered to give me a hint on what to do, maybe because the problems with the new version of iTunes are really a lot, there is an enormous amount of people out there that have all sort of different problems including mine  so I have decided to return to the previous version which works fine and wait untill the apple people come up with a decent product ....

  • HT1351 in my itunes i hit sync selected playlist etx. and it syncs the whole thing how do i fix it..?

    please help in my itunes i hit selected playlist music etx. and it syncs all my music and i have a lot of music and it is very very frustrating.. please help me fix this stupid problem

    Oh also I forgot to mention: when I try to download a rar file and I tell it to open, it downloads it in full, and opens it perfectly. I cannot see the status of that download though, as my downloads window is always blank

Maybe you are looking for