Subquery MySql 1 [duplicate]

-1

Motta,

Thanks for the agility, but this instruction is appearing only the highest salary. I tried INNER JOINT, and I almost did it. Imagine that I want to compare the salary of people with the same job. See if you can understand with the attached image.

Friends,

I would like your help in MySql, I have a table of employees that has only three columns, NAME, POST and SALARY, I want to set up a query that brings me this whole table and contains the highest salary value for the position. Totalizing 4 Columns (NAME, CHARGE, SALARY AND MAIOR_SALARIO_P_CARGO This is to check the variation.

    
asked by anonymous 15.05.2014 / 17:46

1 answer

1

Hello, I believe that this query can solve, I did not get to test it.

SELECT
    T1.NOME,
    T1.CARGO,
    T1.SALARIO_ATUAL,
    (
        SELECT MAX(SALARIO_ATUAL)
        FROM TABELA T2
        WHERE T2.CARGO = T1.CARGO
    ) AS MAIOR_SALARIO_PARA_CARGO
FROM TABELA T1
    
15.05.2014 / 17:58