2
I have a table with columns nome, salario and alocacao.
How do I select only the worker who has the highest salary and who has the value mg in the column alocacao, unused MAX()?
2
I have a table with columns nome, salario and alocacao.
How do I select only the worker who has the highest salary and who has the value mg in the column alocacao, unused MAX()?
6
SELECT
nome, salario
FROM empregados
WHERE alocacao="mg"
ORDER BY salario DESC
LIMIT 1
Split:
nome, salario, the columns you want to appear in the resultFROM empregados, the table nameWHERE alocacao="mg", the condition to check, ie. only bring result(s) that had(m) the value of the column alocacao equal to `mg``ORDER BY salario, sort by column value salarioDESC, make the ordination be in descending order (from the largest to the smallest)LIMIT 1, bring only one resultBrowser other questions tagged mysql
You are not signed in. Login or sign up in order to post.