Skip to content
Advertisement

Oracle 10g sql query

I have some data like this ↓

This table only has insert,during insert T_UPDATE_COUNT = max(T_UPDATE_COUNT) + 1 ;

I want the data to look like this ↓

How do i write SQL statement ?

Advertisement

Answer

Assuming that you need to get all the rows with the maximum value of T_UPDATE_COUNT for each T_PERIOD , you may try:

There are different ways to do this; I believe this one is clear enough: the inner query is used to compute the row number in the set of all the rows with the same value of T_PERIOD (partition by T_PERIOD) and name it RN. The external one simply filters this result to only get the first rows (RN = 1) of each group.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement