现在有表tabel1 包括字段A,B,CA B C
E001 20 2006/11/7
E001 40 2006/11/20
E002 50
E003 2007/1/1
现在要求的结果是:
A B C
E001 20或40 2006/11/7或2006/11/20
E002 50
E003 2007/1/1
也就是说A的值只出现一次,其它的取作一值都可以
请问这个SQL如何写呢
E001 20 2006/11/7
E001 40 2006/11/20
E002 50
E003 2007/1/1
现在要求的结果是:
A B C
E001 20或40 2006/11/7或2006/11/20
E002 50
E003 2007/1/1
也就是说A的值只出现一次,其它的取作一值都可以
请问这个SQL如何写呢
这样写可对?
(select row_number()over(partition by a order by a) rn,a,b,c from table1)
where rn=1
from table
where rowid in (select rowid from table group by a having rownum = 1)
select distinct A, B, C from table1;
你改成Oracle试一下捏!实在不行就用游标.反正这问题能搞定
from table
where rowid in (select MAX(rowid) from table group by a )他那个我这里运行不了好像,这个错,ORA-00979: not a GROUP BY expression
所以小改了一下。