N
N
nyatmeat152018-10-29 16:36:32
SQL
nyatmeat15, 2018-10-29 16:36:32

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

3 answer(s)
N
nyatmeat15, 2018-10-29
@nyatmeat15

https://stackoverflow.com/questions/39885926/select...

P
ponaehal, 2018-10-29
@ponaehal

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

K
Konstantin Tsvetkov, 2018-10-29
@tsklab

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 question

Ask a Question

731 491 924 answers to any question