var fun = ABS_LOADBEAN("com.plug.FunctionHelper");
//var v_div = fun.funHelper.strAdd("'<div>'","b.Day");
//v_div = fun.funHelper.strAdd(v_div,"'</div>'");
var v_div = "'<div>'||"+"b.Day"+"||'</div>'";
var sql = " select max(ID) ID,NoofWeek,max(Week1) Week1,max(Week2) Week2,max(Week3) Week3,max(Week4) Week4,max(Week5) Week5,max(Week6) Week6,max(Week7) Week7 "
+" from ( "
+" select a.ID,to_number(to_char(b.Year)||(CASE WHEN b.NoofWeek>=10 THEN to_char(b.NoofWeek) ELSE '0'||to_char(b.NoofWeek) END)) as NoofWeek,"
+" case when b.Week=1 then "+v_div+" else '' end as Week1,"
+" case when b.Week=2 then "+v_div+" else '' end as Week2,"
+" case when b.Week=3 then "+v_div+" else '' end as Week3,"
+" case when b.Week=4 then "+v_div+" else '' end as Week4,"
+" case when b.Week=5 then "+v_div+" else '' end as Week5,"
+" case when b.Week=6 then "+v_div+" else '' end as Week6,"
+" case when b.Week=7 then "+v_div+" else '' end as Week7 "
+" from T_HR_WorkCalendar a,tCalendar b"
+" where a.FAttendPeriod={0} and a.FWorkType={1} and to_char(a.FWorkDate,'yyyyMMdd')=b.ID and funit = {2}"
+" ) x"
+" group by NoofWeek"
+" order by Noofweek";
sql