select AAA,max(BBB) as BBB,max(CCC) as CCC from 表 group by AAAselect AAA,min(BBB) as BBB,min(CCC) as CCC from 表 group by AAA
取任意的BBB,CCC是要有策略的,比如取行号最大的这样写: SELECT B.AAA,A.BBB.A.CCC (select AAA,BBB,CCC,ROWNUM AS id from table_name ) A, (select AAA,max(rownum) as id from table_name group by AAA ) B WHERE A.id = B.id
忘了说了, AAA = 2的时候 取到的值只能是 AAA BBB CCC 2 B A 或 2 A C 也就是说BBB和CCC里的内容要是同一条记录的.
select aaa,max(bbb),max(ccc) from table1 group by aaa
select aaa,bbb,ccc from t1, ( select aaa,max(rowid) max_rowid from t1 group by aaa) t2 where t1.rowid = t2.rowid
SELECT B.AAA,A.BBB.A.CCC
(select AAA,BBB,CCC,ROWNUM AS id from table_name ) A,
(select AAA,max(rownum) as id from table_name group by AAA ) B
WHERE A.id = B.id
AAA = 2的时候
取到的值只能是
AAA BBB CCC
2 B A
或
2 A C
也就是说BBB和CCC里的内容要是同一条记录的.
aaa,max(bbb),max(ccc)
from table1
group by aaa
from t1,
(
select
aaa,max(rowid) max_rowid
from t1
group by aaa) t2
where t1.rowid = t2.rowid