简单的结构如下:
表tt
id name tel
1 m 12345
1 m 12345
1 m
2 w
3 c 23434
4 t
要查询的结果
id name tel
1 m 12345
2 w
3 c 23434
4 t
如果相同id值的取tel有数据一条
表tt
id name tel
1 m 12345
1 m 12345
1 m
2 w
3 c 23434
4 t
要查询的结果
id name tel
1 m 12345
2 w
3 c 23434
4 t
如果相同id值的取tel有数据一条
解决方案 »
- ant脚本运行sql出错,但是sql语句没有任何问题
- 求 系统内主数据等基础数据表结构设计 好的办法、方案
- 请问有没Oracle Developer 的触发器文档参考?
- oracle多个sequence对象批量增值
- cman(connect manager)连接管理器不能用?
- jsp 对oracle 表的查询结果无显示
- ORACLE数据移值(ORACLE for LINUX V. TO ORACLE FOR w2k V.)
- 请问:我想只取第100到300条的纪录,应该怎么做呢?
- 刚才还好使,转眼就TNS:lost connect了
- 请教一个SQL 请大神们 指教
- 不能在手动或分布事务方式下创建新的连接
- 求教一个函数~
select id, name, tel
from (select id, name, tel,
row_number() over(partition by id, name order by tel) as isort
from table_name) t
where isort = 1;
select *
from (
select id, name, max(tel) tel
from tt
group by id, name
)
order by id;
with tb1 as (
select 1 id,'m' name,12345 tel from dual union all
select 1 id,'m' name,12345 tel from dual union all
select 1 id,'m' name,null tel from dual union all
select 2 id,'w' name,null tel from dual union all
select 3 id,'c' name,23434 tel from dual union all
select 4 id,'t' name,null tel from dual
)
select max(id) id,name,max(tel) tel from tb1 group by name order by id;