如何对列的数据进行排序
例如有表TABLE_TEST
id count_1 count_2 count_3 count_4 count_5
1 5 6 1 2 4
2 4 7 1 5 9
...............................
如何才能得到数据
id count_1 count_2 count_3 count_4 count_5
1 1 2 4 5 6
2 1 4 5 7 9能不能不使用循环对每天单独提取出来进行处理
因为数据量可能会上千万...有好的意见或者建议请不吝留言..
不省感激
例如有表TABLE_TEST
id count_1 count_2 count_3 count_4 count_5
1 5 6 1 2 4
2 4 7 1 5 9
...............................
如何才能得到数据
id count_1 count_2 count_3 count_4 count_5
1 1 2 4 5 6
2 1 4 5 7 9能不能不使用循环对每天单独提取出来进行处理
因为数据量可能会上千万...有好的意见或者建议请不吝留言..
不省感激
解决方案 »
- 【面试题】某表定期删除之前的数据,求教该表设计要点
- 关于oracle时间问题?
- 为什么v$database 视图中的flashback_on 字段为NO,我仍然能闪回表呢?
- sql语句,高手帮忙!
- oracle字符串分割问题!!求教大神!!
- 请问Oracle 是不是把它管理的数据空间全部或分为 "表空间"这个东西? 新建用户的时候都要指定表空间
- pl/sql 登陆之后是否就连上了数据库,还是要new database link? 连接上数据库之后是下一步要干啥呢?
- 关于触发器的一个小问题(在线等待)
- 一个select语句该怎么写
- 存储过程的问题(在线等待)
- 一个oracle错误。
- 如何估计Oracle中一张表占用的表空间大小?
---------- ---------- ---------- ---------- ---------- ----------
1 5 6 1 2 4
2 4 7 1 5 9SQL>
SQL> select id,r1,r2,
2 greatest(decode(t1,r1,0,r2,0,r4,0,r5,0,t1),
3 decode(t2,r1,0,r2,0,r4,0,r5,0,t2),
4 decode(t3,r1,0,r2,0,r4,0,r5,0,t3),
5 decode(t4,r1,0,r2,0,r4,0,r5,0,t4),
6 decode(t5,r1,0,r2,0,r4,0,r5,0,t5)) r3
7 ,r4,r5
8 from (
9 select id,r1,least(decode(t1,r1,999,r5,999,t1),decode(t2,r1,999,r5,999,t2),decode(t3,r1,999,r5,999,t3),decode(t4,r1,999,r5,999,t4),decode(t5,r1,999,r5,999,t5)) r2,
10 greatest(decode(t1,r1,0,r5,0,t1),decode(t2,r1,0,r5,0,t2),decode(t3,r1,0,r5,0,t3),decode(t4,r1,0,r5,0,t4),decode(t5,r1,0,r5,0,t5)) r4,r5,t1,t2,t3,t4,t5
11 from (
12 select least(t1,t2,t3,t4,t5) r1,greatest(t1,t2,t3,t4,t5) r5,id,t1,t2,t3,t4,t5 from test
13 ))
14 / ID R1 R2 R3 R4 R5
---------- ---------- ---------- ---------- ---------- ----------
1 1 2 4 5 6
2 1 4 5 7 9呵呵,没办法写了个很苯的sql,千万别这样.权当练手.
least()
greatest()
这两个函数我还没用过.学习一下,
再等等看有没其他高人再指教一下