[Solved] How to get value from a table base on “Preference” [closed]


This might be slightly off as mysql dialect always throws me. Since B falls after A in an alphabetical sort, if you group on the ID and then select the maximum, it will give you all the B rows where they exist, otherwise you will get the A row.

SELECT
    ID,
    MAX(alphabet) AS preference
FROM
    t1
GROUP BY
    ID

Now, if your data is more complex than what you’ve indicated, you will need to examine whether the MAX logic still applies.

3

solved How to get value from a table base on “Preference” [closed]