The select tt. *,
(the select t4. Addvnm
The from st_addvcd_d_loc t4
Where tt. Addvcd=t4. Addvcd
Group by t4. Addvnm) qu
The from (select t.a DDVCD, t.s TNM, sum (t.d yp) sumdyp
The from (select t1 STCD, t1 dyp, t2. STNM, t2. Addvcd, t3. Addvnm
The 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.a DDVCD, t.s TNM
The order by sumdyp desc) tt
CodePudding user response:
Such as 1, 2 line how the other columns show?CodePudding user response:
What kind of results?CodePudding user response:
Qu columns cannot have duplicate, in the process of to weigh the sumdyp shall prevail, only the maximum of the qu information, for example, fuling have 2 lines, corresponding sumdyp information is 5.5 and 3.5, only 5.5 this line information (other corresponding column to display).CodePudding user response:
select addvcd, STNM sumdyp, qu
The from (select addvcd,
STNM,
Sumdyp,
Qu,
Row_number () over (partition by qu order by sumdyp desc) rn
From the table name)
Where an rn=1