How to "Type" column of the same Type, and the ID is one of the biggest lines of the last update field value?
Such as to make the following format:
CodePudding user response:
- using ROW_NUMBER function add a sorting, grouped by type and according to the value of reverse
The SELECT ROW_NUMBER () OVER (PARTITION BY Type order BY Value desc) as No,
* From Table
- then put NO=1 Flag update into 1 (because the above is according to the Value) can be reverse
CodePudding user response:
The UPDATE TBDATA SET FLAG=1The WHERE (ID, TYPE) IN (SELECT MAX (ID), TYPE the FROM TBDATA GROUP BY ID);