日期:2014-05-17  浏览次数:20980 次

求SQL语句。。。
麻烦先看看要求,上个帖子已经结贴了,但是要求又增加了一点。。

http://topic.csdn.net/u/20120531/14/b685e5c2-9e02-4a88-b0d6-76e7ced608ad.html

要求在我最后回复的楼层里。。

------解决方案--------------------
测试数据:

SQL code
create table tab_test as
select 1 as can_use, to_date('2012-01-14 0:10:00', 'yyyy-MM-dd HH24:mi:ss') as c_date , '繁忙' as des,''
CAR_USE_MODE,'' USE_NO from dual
union all
select 1 as can_use, to_date('2012-01-14 0:20:00', 'yyyy-MM-dd HH24:mi:ss') as c_date , '繁忙' as des,'','' from dual union all
select 1 as can_use, to_date('2012-01-14 0:30:00', 'yyyy-MM-dd HH24:mi:ss') as c_date , '繁忙' as des,'','' from dual union all
select 1 as can_use, to_date('2012-01-14 0:40:00', 'yyyy-MM-dd HH24:mi:ss') as c_date , '繁忙' as des,'','' from dual union all
select 1 as can_use, to_date('2012-01-14 0:50:00', 'yyyy-MM-dd HH24:mi:ss') as c_date , '繁忙' as des,'','' from dual union all
select 1 as can_use, to_date('2012-01-14 1:00:00', 'yyyy-MM-dd HH24:mi:ss') as c_date , '繁忙' as des,'','' from dual union all
select 0 as can_use, to_date('2012-01-14 1:10:00', 'yyyy-MM-dd HH24:mi:ss') as c_date , '空闲' as des,'租赁','HT12011600402' from dual 
union all
select 0 as can_use, to_date('2012-01-14 1:20:00', 'yyyy-MM-dd HH24:mi:ss') as c_date , '空闲' as des,'租赁','HT12011600402' from dual 
union all
select 0 as can_use, to_date('2012-01-14 1:30:00', 'yyyy-MM-dd HH24:mi:ss') as c_date , '空闲' as des,'租赁','HT12011600402' from dual 
union all
select 0 as can_use, to_date('2012-01-14 1:40:00', 'yyyy-MM-dd HH24:mi:ss') as c_date , '空闲' as des,'租赁','HT12011600402
' from dual 
union all
select 0 as can_use, to_date('2012-01-14 1:50:00', 'yyyy-MM-dd HH24:mi:ss') as c_date , '空闲' as des,'租赁','HT12011600402' from dual 
union all
select 0 as can_use, to_date('2012-01-14 2:00:00', 'yyyy-MM-dd HH24:mi:ss') as c_date , '空闲' as des,'租赁','HT12011600402' from dual 
union all
select 1 as can_use, to_date('2012-01-14 2:10:00', 'yyyy-MM-dd HH24:mi:ss') as c_date , '繁忙' as des,'租赁','HT12011600402' from dual;

------解决方案--------------------
这个还好 偶上次回复的那个才是体力活 一天多 就为了回复一个sql