一张表无主键,也就是可能存在重复纪录
在选择数据时,我这样写了一条语句,使用distinct避免重复纪录, 用code1,code2排序。
可是这样会报错。
select distinct name1,name2,note
from DFW_MD0M
ORDER BY code1,code2
我该怎样排序呢?
在选择数据时,我这样写了一条语句,使用distinct避免重复纪录, 用code1,code2排序。
可是这样会报错。
select distinct name1,name2,note
from DFW_MD0M
ORDER BY code1,code2
我该怎样排序呢?
from
(select t.*,row_number() over(partition by name1,name2 order by name1,name2) rn from tb)
where rn=1;
from
(select t.*,row_number() over(partition by name1,name2 order by name1,name2) rn from tb t)
where rn=1;
ORA=01791:SELECT式无效
SELECT distinct name1,name2, note, code1, code2
FROM DFW_MD0M
ORDER BY code1,code2)