有两个表
A B
a b b c
1 47 47 1M
1 56 56 3G
2 33 33 1K
2 67 67 8K
2 9 9 7M
3 7 7 自定义
... ... ... ...
-------------------------------------
A,B关系如上 通过b的值关联
a速率的值=相应的b所对应的c的最大值
现在要统计a及其对应的值
-------------------------------------
关键是c里面有中文和字母
A B
a b b c
1 47 47 1M
1 56 56 3G
2 33 33 1K
2 67 67 8K
2 9 9 7M
3 7 7 自定义
... ... ... ...
-------------------------------------
A,B关系如上 通过b的值关联
a速率的值=相应的b所对应的c的最大值
现在要统计a及其对应的值
-------------------------------------
关键是c里面有中文和字母
select a.a,max(b.c)
from a,b
where a.b=b.b
group by a.a
b,
c, case when c='自定义' then
4
when substr(c,Length(c)-1,1)='K' then
3
when substr(c,Length(c)-1,1)='M' then
2
when substr(c,Length(c)-1,1)='G' then
1
end as c1, case when c='自定义' then
99 --注1
else
substr(c,1,Length(c)-1) --这里是取c的字母前的数据,如果不超过2位,上面的‘注1’就用99即可。
end as c2from B表order by c1,c2
2)把上面的1)数据与表A关联,c1,c2只参与排序即可,不用我再写了吧!1)的细节你要再调调。