select tt.*,
(select t4.addvnm
from st_addvcd_d_loc t4
where tt.addvcd = t4.addvcd
group by t4.addvnm) qu
from (select t.addvcd, t.stnm, sum(t.dyp) sumdyp
from (select t1.stcd, t1.dyp, t2.stnm, t2.addvcd, t3.addvnm
from st_pptn_r_loc t1,
st_stbprp_b_loc t2,
st_addvcd_d_loc t3
where dyp is not null
and t1.stcd = t2.stcd
and t2.addvcd = t3.addvcd) t
group by t.addvcd, t.stnm
order by sumdyp desc) tt
4 个解决方案
#1
比如1 2行其他的列怎么显示?
#2
结果要什么样的呢?
#3
qu列不能有重复的,在去重的过程中以sumdyp为准,只留最大值所对应的qu信息。例如,涪陵区有2行,所对应的sumdyp信息是5.5和3.5,只留5.5这行信息(其它所对应的列都要显示)。
#4
select addvcd, stnm, sumdyp, qu
from (select addvcd,
stnm,
sumdyp,
qu,
row_number() over(partition by qu order by sumdyp desc ) rn
from 表名)
where rn = 1
#1
比如1 2行其他的列怎么显示?
#2
结果要什么样的呢?
#3
qu列不能有重复的,在去重的过程中以sumdyp为准,只留最大值所对应的qu信息。例如,涪陵区有2行,所对应的sumdyp信息是5.5和3.5,只留5.5这行信息(其它所对应的列都要显示)。
#4
select addvcd, stnm, sumdyp, qu
from (select addvcd,
stnm,
sumdyp,
qu,
row_number() over(partition by qu order by sumdyp desc ) rn
from 表名)
where rn = 1