简体   繁体   中英

ORACLE Extract last data with different keys within the table

DATA

A1 - B1 - DATA1
A1 - B1 - DATA2
A1 - B1 - DATA3
A1 - B2 - DATA1
A1 - B2 - DATA2
A1 - B3 - DATA1
A1 - B3 - DATA2
A1 - B3 - DATA3

Desired results

A1 - B1 - DATA3
A1 - B2 - DATA2
A1 - B3 - DATA3

Extract only the last data from each second column The third column [DATA] does not need to be sorted.

Based on your sample data, it seems that you want a simple group by:

select column_1, column_2, max(column_3)
from the_table
group by column_1, column_2
order by column_1, column_2;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM