一个查询语句问题
有一个表主内容如下(id   为char型   ,版本版次为INT型,三项组合不重复) 
 ID(docno   )      版本(edition)      版次(bc) 
 CH001                              1                                       1 
 CH001                              1                                       2 
 CH001                              1                                       3 
 CH001                              2                                       1 
 CH001                              2                                       2 
 CH002                              1                                       1 
 CH003                              1                                       1 
 CH003                              1                                       2   
 我想得到的结果是每个不同ID以及相应的最大版本,版次(版本优先考虑)结果如下: 
 CH001                              2                                       2 
 CH002                              1                                       1 
 CH003                              1                                       2     
 语句该怎么写啊?想了好久竟然没想出来!   
------解决方案--------------------Select A.* From 表 A 
 Inner Join 
 (Select docno, Max(edition) As edition From 表 Group By docno) B 
 On A.docno = B.docno And A.edition = B.edition 
 Inner Join 
 (Select docno, edition, Max(bc) As bc From 表 Group By docno, edition) C 
 On A.docno = C.docno And A.edition = C.edition And A.bc = C.bc
------解决方案--------------------select * from tablename a 
 where not exists ( 
 select 1 from tablename 
 where id=a.id 
 and (版本> a.版本 or 版本=a.版本 and 版次> a.版次) 
 )