Home Forums SQL Server 2012 SQL Server 2012 - T-SQL SQL Query to find all the employee whose salary sum is 80% of sum of salary of all employee. RE: SQL Query to find all the employee whose salary sum is 80% of sum of salary of all employee.

  • akash_singh (8/14/2014)


    Let us assume that there are 100 employee in a company. And sum of salary of all employee is 10000. Find list of highest paid employees whose sum of salary is 8000. Remaining employee will fall in 20% bracket. I hope question is clear. Please let me know if anything else is required.

    How many employees and how often do you need to do this? I ask because there aren't many good (horrible, horrible performance or some nasty trick code to get performance) options in 2008 although there are some easy ones. We need to know so we can figure out the "best" option for you.

    I share the sentiment. It would be nice if you had provided some test data and posted to the correct forum. 😉 See the first link in my signature line under "Useful Links" to learn how to create readily consumable test data in a hurry.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)