解决方案 »
- 谁能给个建议:学习oracle比较好的视频教程?
- sql查询m时间内,出现频度n以上的记录。例如:表中记录日期与天气,查询3天内出现2天雨以上的日期起期。
- 帮忙解决下这个orcale存储过程!!!!!!!!!!!!
- 50分求救,在硬盘中删除了一个ybzf.ORA,现在启动数据库有问题了
- 在线等待,当场解决当场给分,关于新建数据库的问题?
- 在ORACLE 8i中进入SQLPLUS登陆后出现ORA-12547:TNS:丢失联系错误;进入DBA后连接数据库时根本没响应。
- 字符集的问题 中文乱码
- 请教一个在8。0。5版本中用系统工具和手工方式建立数据库及相关对象的例子!
- 新人求教,如何取得表中50%的数据?
- Oracle Change Notification 延时严重怎么解决?
- sql语句转换 存储过程 问题
- 关于group by
select 1 id ,date '2011-12-2' ddate, '09:30' begin, '10:00' end from dual union all
select 1 id ,date '2011-12-2' ddate, '10:30' begin, '11:00' end from dual union all
select 1 id ,date '2011-12-3' ddate, '09:30' begin, '10:00' end from dual union all
select 2 id ,date '2011-12-2' ddate, '09:30' begin, '10:00' end from dual union all
select 2 id ,date '2011-12-2' ddate, '10:30' begin, '11:00' end from dual union all
select 2 id ,date '2011-12-4' ddate, '09:30' begin, '10:00' end from dual union all
select 3 id ,date '2011-12-2' ddate, '09:30' begin, '10:00' end from dual union all
select 3 id ,date '2011-12-2' ddate, '10:30' begin, '11:00' end from dual union all
select 3 id ,date '2011-12-4' ddate, '09:30' begin, '10:00' end from dual
)
select id ,wm_concat(a),wm_concat(b),wm_concat(c) from (
select id,decode(to_char(ddate,'dy'),'星期五',(begin||'-'||end)) a,
decode(to_char(ddate,'dy'),'星期六',(begin||'-'||end)) b,
decode(to_char(ddate,'dy'),'星期日',(begin||'-'||end)) c
from t ) tt
group by tt.id
----- 1 09:30-10:00,10:30-11:00 09:30-10:00
2 09:30-10:00,10:30-11:00 09:30-10:00
3 09:30-10:00,10:30-11:00 09:30-10:00
with t as (
select 1 id ,date '2011-12-2' ddate, '09:30' begin, '10:00' end from dual union all
select 1 id ,date '2011-12-2' ddate, '10:30' begin, '11:00' end from dual union all
select 1 id ,date '2011-12-3' ddate, '09:30' begin, '10:00' end from dual union all
select 2 id ,date '2011-12-2' ddate, '09:30' begin, '10:00' end from dual union all
select 2 id ,date '2011-12-2' ddate, '10:30' begin, '11:00' end from dual union all
select 2 id ,date '2011-12-4' ddate, '09:30' begin, '10:00' end from dual union all
select 3 id ,date '2011-12-2' ddate, '09:30' begin, '10:00' end from dual union all
select 3 id ,date '2011-12-2' ddate, '10:30' begin, '11:00' end from dual union all
select 3 id ,date '2011-12-4' ddate, '09:30' begin, '10:00' end from dual
)
这些语句的目的是为了建立测试数据,你有实际的表,不用写前面这些。
直接从实际表中的查询即可。