mysql - Get Highest value from items with same IDs -



mysql - Get Highest value from items with same IDs -

i have table this:

id severity workitemsk 23636 3-minor 695119 23636 3-minor 697309 23647 2-major 695081 23647 2-major 694967

in here have several workitems share same id. how can unique ids have highest workitem?

so this:

id severity workitemsk 23636 3-minor 697309 23647 2-major 695081

help noob :) mind giving clue sql commands (again noob) should use? or illustration of query?

thank in advance!

assuming severity can alter depending on workitemsk, you'll want utilize next query:

select t.id, t.severity, t.workitemsk table t bring together ( select id, max(workitemsk) workitemsk table grouping id ) d on t.workitemsk = d.workitemsk , t.id = d.id

the lastly join status of t.id = d.id may or may not needed, depending on whether workitemsk can appear multiple times in table.

otherwise, can utilize this:

select id, severity, max(workitemsk) workitemsk table grouping id, severity

but if have different severity values per id, you'll see duplicate ids.

mysql sql

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -