select n1,n2,n3 from (select n1,n2,n3,row_number() over(partition by n1 order by n2 desc,n3) rm from test) a where a.rm=1;
to:bobfang(匆匆过客)from (select b.n1, max(b.n2) n2 from test b group by b.n1) a * ERROR at line 2: ORA-00979: not a GROUP BY expression
select n1(distinct) ,n2,n3 from (select n1,n2,n3 from test group by n1 order by n2 desc , n3 asc)
凑个数 select c.n1,c.n2,c.n3 from (select distinct n1 from test) A, (select n1,max(n2) from test group by n1) b, (select n1,n2,min(n3) from test group by n1,n2) c where A.n1=C.n1 and A.n1=C.n1 and B.n2=C.n2
to:wangrong001(wr001): select n1,n2,n3 from test group by n1 order by n2 desc , n3 asc n2,n3不在group之列?to:sunlight1234(bugbugbug) max(n2)...要起个别名就可以了。谢谢大家。 结贴。
*
ERROR at line 2:
ORA-00979: not a GROUP BY expression
select c.n1,c.n2,c.n3
from
(select distinct n1 from test) A,
(select n1,max(n2) from test group by n1) b,
(select n1,n2,min(n3) from test group by n1,n2) c
where A.n1=C.n1
and A.n1=C.n1
and B.n2=C.n2
select n1,n2,n3 from test group by n1 order by n2 desc , n3 asc
n2,n3不在group之列?to:sunlight1234(bugbugbug)
max(n2)...要起个别名就可以了。谢谢大家。
结贴。