Answer the question
In order to leave comments, you need to log in
How to get posts with maximum revision?
Table structure
id int
departmentId int
type int
revision int
How to get records with maximum revision?
i.e. grouped by fields id, departmentId, type
Answer the question
In order to leave comments, you need to log in
It is generally useless to group by the id field, because it is unique for each record. If without it, then like this:
SELECT departmentId, type, MAX(revision) from table_name GROUP BY departmentId, type
How to get posts with maximum revision?Literally, the answer was already recently: link the result to the table itself .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question