Note that there are some explanatory texts on larger screens.

plurals
  1. POMYSQL - returning only max result from an ID
    primarykey
    data
    text
    <p>I wasn't quite sure how to title it as its quite a strange question. I'm building a slightly advanced query and it all it works fine except it returns all information under that ID</p> <p>Below is my code:</p> <pre><code>select surname, salary_per_year, position _held, grade, name from person inner join career_history on person.person_id = career_history.person_id join grade on grade.person_id = career_history.person_id join school on grade.school_id = school.school_id where salary_per_year &gt; 20000 and grade &gt;65; </code></pre> <p>This creates this table. </p> <pre><code>+----------+-----------------+--------------------+-------+---------------------------+ | surname | salary_per_year | position_held | grade | name | +----------+-----------------+--------------------+-------+---------------------------+ | webster | 32000 | data analyst | 78 | Oxford University | | webster | 23000 | data analyst | 78 | Oxford University | | molina | 21000 | receptionist | 81 | UNAM | | jones | 22000 | law assistant | 69 | University of Queensland | | jones | 39000 | junior lawyer | 69 | University of Queensland | | lovely | 26000 | junior analyst | 71 | Univesity of Bristol | | clark | 23000 | junior banker | 68 | Harvard Univeristy | | clark | 65000 | head banker | 68 | Harvard Univeristy | | roberts | 26000 | researcher | 69 | MIT | | roberts | 32000 | teacher | 69 | MIT | | knght | 28000 | head of department | 92 | University of Barcelona | | knght | 39000 | campus director | 92 | University of Barcelona | | yanagowa | 39000 | database manager | 86 | Oxford Brookes Univeristy | | yanagowa | 55000 | head of data | 86 | Oxford Brookes Univeristy | +----------+-----------------+--------------------+-------+---------------------------+ </code></pre> <p>My question is how do I make it only show the highest salary per surname. e.g</p> <p>yanagowa 55000 head of data 86 Oxford Brookes University not Yanagowa 39000 database maanger 86 oxford brookes univeristy</p> <p>please could someone point me in the right direct!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload