使用oracle 统计月考勤显示问题

现在表结构如下:
人员姓名、考勤类型、考勤日期
张三 早班 2011-10-1
张三 中班 2011-10-2
张三 晚班 2011-10-3
张三 晚班 2011-10-8
张三 晚班 2011-10-11

其中早班(☆)、中班(#) 、晚班(√)
现在需要用sql语句查询如下显示格式:
姓名 1 2 3 4 5 6 7 8 9 10 11.........31
张三 ☆ # √ √ √

希望给个解答 小弟不才 分数用完了

第1个回答  2011-10-12
用子查询+“case when” or “decode”~
select (select decode(t.类型,'早班','☆','中班','#','晚班','√',null) from table t where t.name= t1.name
and t.考勤时间=1) 1,
(select decode(t.类型,'早班','☆','中班','#','晚班','√',null) from table t where t.name= t1.name
and t.考勤时间=2) 2,
(select decode(t.类型,'早班','☆','中班','#','晚班','√',null) from table t where t.name= t1.name
and t.考勤时间=3) 3,
.......N
from (select distinct name table) t1;

注:
考勤时间需要自己转换成天数
t.类型 需要改成table对应的类型字段
第2个回答  2011-10-11
二维格式用sql没法做 sql是用了查找数据的 显示格式这个是界面编程完成的本回答被网友采纳