Skip to content
Advertisement

MySQL #1140 – I want to display the minimum salary, it gives this error

I want to display the minimum salary, it gives this error I have to take out one person who gets the lowest salary not using group by

SELECT
    MIN(salary) as 'min_salary',
    name_surname
FROM
    player,
    contracts
WHERE
    player.id = contracts.id
LIMIT 0, 50

MySql error:

#1140 – In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column ‘football_club.player.name_surname’; this is incompatible with sql_mode=only_full_group_by

Advertisement

Answer

I’m editing the answer as now the question is more clear.

You can extract the persons with the lowest salaries with:

SELECT
    salary,
    name_surname
FROM
    player
WHERE salary = (SELECT MIN(salary) FROM player)

Of course you’ll have more than one row if more player has the lowest salary

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement