Multiple methods for querying the maximum time record in a group: [SQL] create table dispatch_result (dr_id number not null, sheet_id number, check_next varchar (20), check_time date, check_sn char (8), check_comment varchar (255), check_status number, constraint PK_RESULT primary key (dr_id); Sequence Table Record: DR_ID SHEET_ID CHECK_NEXT CHECK_TIME CHECK_SN 1_check_status -------------- skip ---- failed ------------------------------------------------------- ---- -------------------------------------------------------------------------------- ------------ 1 1 10001 2012/8/12 11:11:23 10000 1 2 1 10002 2012/9/15 11:15:24 10001 2 3 2 10001 2012/8/15 9:16:10 10000 1 4 2 10002 2012/9/18 11:16:23 10001 2 query the maximum time record for the SHEET_ID group: method 1: [SQL] select * from dispatch_result dr where dr. check_time = (select max (check_time) from dispatch_result where sheet_id = dr. s Heet_id) DR_ID SHEET_ID CHECK_NEXT CHECK_TIME CHECK_SN CHECK_COMMENT CHECK_STATUS ------------ hour ------------- -------- hour -------------- 2 1 10002 hour 11:15:24 10001 2 4 2 10002 hour 11:16:23 10001 2 www.2cto.com second group by mode: [SQL] select t1. * from dispatch_result t1 right join (select Sheet_id, max (check_time) ct from dispatch_result group by sheet_id) t2 on KERNEL _ id = KERNEL _ id and t2.ct = t1.check _ time DR_ID SHEET_ID CHECK_NEXT CHECK_TIME CHECK_SN CHECK_COMMENT CHECK_STATUS ------------ kernel ----------- -------- kernel ------------ 2 1 10002 bytes 11:15:24 10001 2 4 2 10002 11:16:23 10001 2 or [SQL] select * from dispatch_result inner join (select max (dr. check_time) as check_time, dr. sheet_id from dispatch_result dr group by dr. sheet_id) t1 using (check_time, sheet_id); www.2cto.com CHECK_TIME SHEET_ID DR_ID CHECK_NEXT CHECK_SN CHECK_COMMENT CHECK_STATUS ----------- ---------- -------------------- accept --------------------------------------------------------------------------------------------------------- -------------------------------- ------------ 11:15:24 1 2 10002 10001 22012/9/18 11:16:23 2 4 10002 10001 2 3 partition by method: [SQL] select t2. * from (select t1. *, row_number () over (partition by t1.sheet _ id order by t1.check _ time desc nulls last) rn from dispatch_result t1) t2 where rn = 1 hour DR_ID SHEET_ID CHECK_NEXT CHECK_TIME CHECK_SN CHECK_COMMENT CHECK_STATUS --------------- ----- -------------------- ----------- -------- ------------ 2 1 10002 11:15:24 10001 2 4 2 10002 11:16:23 10001 2 results are the same. For efficiency, please kindly advise. Author hanzhou4519