Top Earners

Sort by

recency

|

3438 Discussions

|

  • + 0 comments
    SELECT (MONTHS * SALARY) AS TOTAL_SALARY , COUNT(*)
    FROM EMPLOYEE
    GROUP BY TOTAL_SALARY 
    ORDER BY TOTAL_SALARY DESC 
    LIMIT 1 ; 
    
  • + 0 comments

    select (select max(salary*months) from employee)|| ' ' || (select count(employee_id) from employee where (salary*months = (select max(salary*months)from employee))) from dual

    These are scalar subqueries that are just having fun

  • + 0 comments

    MS SQL SERVER

    WITH 
    TOTAL_E AS 
    (
        SELECT
            EMPLOYEE_ID,
            SALARY * MONTHS AS TOTAL_SALARY
        FROM EMPLOYEE
    ),
    MAX_TOTAL AS 
    (
        SELECT MAX(TOTAL_SALARY) AS MAX_SALARY
        FROM TOTAL_E
    ),
    NUM_SAL_MAX AS 
    (
        SELECT COUNT(*) AS NUM_EMPLOYEES
        FROM TOTAL_E
        WHERE TOTAL_SALARY = (SELECT MAX_SALARY FROM MAX_TOTAL)
    )
    SELECT 
        CAST(MAX_TOTAL.MAX_SALARY AS VARCHAR) + '  ' + CAST(NUM_SAL_MAX.NUM_EMPLOYEES AS VARCHAR) AS RESULT
    FROM 
        MAX_TOTAL, NUM_SAL_MAX;
    
  • + 0 comments

    SELECT sal, cnt FROM ( SELECT MAX(salary * months) sal, COUNT(employee_id) cnt from Employee Group By salary * months Order By salary * months Desc )d WHERE ROWNUM = 1;

  • + 1 comment

    select max(salary*months), count(employee_id) from employee where salary*months in (select max(salary*months) from employee)