As in 2 columns (salary type and salary value), print the maximum salary value, the minimum and the average from the plate, in which one of the columns contains the salary value of employees.

Closed due to the fact that the essence of the question is incomprehensible by the participants of Streletz , insolor , user194374, pavel , sercxjo 21 Aug '16 at 7:41 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    the structure of the table and a couple of lines give - rjhdby
  • one
    I think you need aggregation functions - min max and avg. - pavel

2 answers 2

SELECT 'MIN' as type, MIN(salary) AS salary FROM table union all SELECT 'MAX' as type, MAX(salary) AS salary FROM table union all SELECT 'AVG' as type, AVG(salary) AS salary FROM table 

    For MySQL in 4 columns

     SELECT MIN(salary), MAX(salary), AVG(salary), type FROM table GROUP BY TYPE 

    In 2 columns

     SELECT salary, type FROM ( SELECT MIN(salary) AS salary, type FROM table GROUP BY TYPE UNION ALL SELECT MAX(salary) AS salary, type FROM table GROUP BY TYPE UNION ALL SELECT AVG(salary) AS salary, type FROM table GROUP BY TYPE ) AS t1 ORDER BY type, salary