一个SQL查询问题,大家关注一下! select a1,a2,a3,a4 from table1 where a1 in (select a1 from table1 group by a1 having count(*) = 1) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不重复的是指不包含重复的吗? 还是在重复的里面仅选择一个?select a1,a2,a3,a4 from t1where rowid in (select min(rowid) from t1 group by a1 having count(*) = 1) select * from tbnamewhere a1 not in(select a1 from tbname group by a1 having count(*)>1); duanzilin(寻) :谢谢你的关注!你上面那种写法会把A1有重复的全部过滤掉的,得不到想要的结果 select * from (select t.*,row_number() over(partition by a1) rn from table1) where rn = 1 漏了点select * from (select t.*,row_number() over(partition by a1) rn from table1 t) where rn = 1 好像不能执行。错误:ORA-30485:在窗口说明中丢失ORDER BY表达式 是不是版本问题,改下试试;select * from (select t.*,row_number() over(partition by a1 order by a2) rn from table1 t) where rn = 1 select * from (select t.*,row_number() over(partition by a1 order by a1) rn from table1 t) where rn = 1 谢谢大家帮忙,问题解决了:)多谢duanzilin(寻)和bluecocoqd(小骗骗) 谁能帮我看下这个 A表两外键 对于B表主键 请问如何建立AB表视图? oracle DG 归档日志不能应用问题 Oracle 主从表联合查询 一条sql语句困惑好久,大家抽空帮我看看吧 求一oracle查询语句 求高手看看这个SQL语句怎么写 创建数据库的问题 请教一个复杂的sql语句 ORA-12514: TNS: 监听进程不能解析在连接描述符中给出的 SERVICE_NAME 错误 帮我啊,面试题目.....(在线等) 有关于查询的问题
select a1,a2,a3,a4 from t1
where rowid in (select min(rowid) from t1 group by a1 having count(*) = 1)
where a1 not in(select a1 from tbname group by a1 having count(*)>1);
你上面那种写法会把A1有重复的全部过滤掉的,得不到想要的结果
select * from (select t.*,row_number() over(partition by a1) rn from table1 t) where rn = 1
错误:
ORA-30485:在窗口说明中丢失ORDER BY表达式
select * from (select t.*,row_number() over(partition by a1 order by a2) rn from table1 t) where rn = 1
(select t.*,row_number() over(partition by a1 order by a1) rn from table1 t)
where rn = 1
多谢duanzilin(寻)和bluecocoqd(小骗骗)