表:
0101 1
0985 0
0985 1
0985 1
1133 0
1385 0
1387 0
是否可以用SQL得出:
0101 1
0985 1
1133 0
1385 0
1387 0
如果第一列相同(例如0985),第二列若有一个记录是1,则取1(例如0985),谢谢指点!
0101 1
0985 0
0985 1
0985 1
1133 0
1385 0
1387 0
是否可以用SQL得出:
0101 1
0985 1
1133 0
1385 0
1387 0
如果第一列相同(例如0985),第二列若有一个记录是1,则取1(例如0985),谢谢指点!
解决方案 »
- Report Builder 中占位的问题?
- 着急在线等!!!!!!!!!!
- RedHat 5 安装 Oracle10g,运行runinstaller 出错(带乱码)
- C#中如何连接oracle数据库连接串如何写
- 如何用oracle语句 实现 表中50行到100 行的显示?
- oracle 10g透明网关问题
- 有没有强行停止oracle的方法,在aix上
- [求助]作为Oracle初学者,应该如何开始学习?
- 文本文件(*.txt)中的数据可以导入到oracle数据库中么,怎么实现的??急急急
- 关键字final 分别修饰一个类,一个方法,一个变量,各起什么作用
- distinct的高级用法,急死了!~
- sql语句怎么写?
select '0101' id,1 num from dual
union all
select '0985' id,0 num from dual
union all
select '0985' id,1 num from dual
union all
select '0985' id,1 num from dual
union all
select '1133' id,0 num from dual
union all
select '1385' id,0 num from dual
union all
select '1387' id,0 num from dual
)
select id,num from (
select id,num,row_number() over(partition by id order by num desc) rn from temp
) where rn = 1
已写入 file afiedt.buf 1 with temp as(
2 select '0101' id,1 num from dual
3 union all
4 select '0985',0 from dual
5 union all
6 select '0985',1 from dual
7 union all
8 select '0985',1 from dual
9 union all
10 select '1133',0 from dual
11 union all
12 select '1385',0 from dual
13 union all
14 select '1387',0 from dual
15 )
16* select id,max(num) from temp group by id
SQL> /ID MAX(NUM)
---- ----------
0101 1
1387 0
0985 1
1133 0
1385 0
select num,max(id) from tb group by num