现在有一个数据库,如下
- HTML code
QUERY_GI HIT_GI QUERY_REF HIT_REF SCORE155041721 155041492 NC_004812 NC_006560 1205155041721 155041491 NC_004812 NC_006560 1008155041721 9629382 NC_004812 NC_001806 996155041721 51557541 NC_004812 NC_006151 746155041721 50313302 NC_004812 NC_001491 718155041721 9629874 NC_004812 NC_001847 714155041721 40787926 NC_004812 NC_005261 696155041721 9629790 NC_004812 NC_001844 694155041721 13242453 NC_004812 NC_002686 670155041721 9625933 NC_004812 NC_001348 662
其中QUERY_GI,HIT_GI为编号,QUERY_REF与HIT_REF分别为QUERY_GI,HIT_GI所在的区域。Score为得分。
现在要得到QUERY_GI,HIT_GI,要求如下:
如果有两个或者两个以上的HIT_GI在同一个HIT_REF中,则选取Score最高的HIT_GI.
比如:
- HTML code
QUERY_GI HIT_GI QUERY_REF HIT_REF SCORE155041721 155041492 NC_004812 NC_006560 1205155041721 155041491 NC_004812 NC_006560 1008
155041492和155041491都在NC_006560区域中,
则选取
QUERY_GI=155041721 HIT_GI=155041492
就可以了
QUERY_GI=155041721和HIT_GI=155041491就不用选取了。
------解决方案--------------------------------------------------------
没看明白 hit_ref惟一吗?如果惟一就 max(score) group by hit_ref
------解决方案--------------------------------------------------------
你的汉语能力很可怜。
分析了一下斧数据,估计你想要的是
"取QUERY_GI , HIT_REF 相同记录中 SCORE 最大的一条记录"
- SQL code
db2# select * from t_yukiooy;
+-----------+-----------+-----------+-----------+-------+
| QUERY_GI | HIT_GI | QUERY_REF | HIT_REF | SCORE |
+-----------+-----------+-----------+-----------+-------+
| 155041721 | 155041492 | NC_004812 | NC_006560 | 1205 |
| 155041721 | 155041491 | NC_004812 | NC_006560 | 1008 |
| 155041721 | 9629382 | NC_004812 | NC_001806 | 996 |
| 155041721 | 51557541 | NC_004812 | NC_006151 | 746 |
| 155041721 | 50313302 | NC_004812 | NC_001491 | 718 |
| 155041721 | 9629874 | NC_004812 | NC_001847 | 714 |
| 155041721 | 40787926 | NC_004812 | NC_005261 | 696 |
| 155041721 | 9629790 | NC_004812 | NC_001844 | 694 |
| 155041721 | 13242453 | NC_004812 | NC_002686 | 670 |
| 155041721 | 9625933 | NC_004812 | NC_001348 | 662 |
| 155041721 | 10140967 | NC_004812 | NC_002531 | 468 |
| 155041721 | 51518047 | NC_004812 | NC_006146 | 463 |
| 155041721 | 82503235 | NC_004812 | NC_007605 | 461 |
| 155041721 | 139424508 | NC_004812 | NC_009334 | 460 |
| 155041721 | 24943128 | NC_004812 | NC_004367 | 452 |
| 155041721 | 13095623 | NC_004812 | NC_002665 | 448 |
| 155041721 | 9629613 | NC_004812 | NC_001826 | 443 |
| 155041721 | 66476626 | NC_004812 | NC_007016 | 435 |
| 155041721 | 18653853 | NC_004812 | NC_003401 | 434 |
| 155041721 | 9628049 | NC_004812 | NC_001650 | 430 |
| 155041721 | 9845402 | NC_004812 | NC_002512 | 425 |
| 155041721 | 9631237 | NC_004812 | NC_001987 | 414 |
| 155041721 | 61660218 | NC_004812 | NC_004065 | 409 |
| 155041721 | 51874301 | NC_004812 | NC_001716 | 406 |
| 155041721 | 139472838 | NC_004812 | NC_009333 | 400 |
| 155041721 | 9626002 | NC_004812 | NC_001350 | 389 |