我想根据一个打卡系统得出当月所有人打卡的明细表:
表名:punch_card_record  
字段:user_id,user_name,record_date(打卡日期 日期类型),onduty_time(上班时间 时间类型),
  offduty_time(下班时间 时间类型)
我现在完成的语句只能实现某一天的查询下:
        X年X月X日                                                                  
张三    √    △   
李四    √    △   
王五    √    △   
我需要得到的表格是这样:
        X年X月X日    X年X月X+1日张三    √    △      √    √
李四    √    △      √    √
王五    √    △      √    △我写的语句如下:
select distinct a.user_id,a.user_name,
((select  case when to_char(b.onduty_time,'hh24:mi')<='09:00' then '√'
 else to_char(b.onduty_time,'hh24:mi') end  from punch_card_record b where b.user_id=a.user_id 
 and b.record_date = to_date('2009-03-01','yyyy-mm-dd' ))||','||
(select  case when b.offduty_time is null then '×'
 when to_char(b.offduty_time,'hh24:mi')>='17:20' then '√' 
 when to_char(b.offduty_time,'hh24:mi')<='17:20' then to_char(b.offduty_time,'hh24:mi') 
 end  from punch_card_record b where b.user_id=a.user_id 
 and b.record_date = to_date('2009-03-01','yyyy-mm-dd' )) ) "1"
from punch_card_record a