两个结果集(所需要的字段和日期字段分组计数合并)成一个结果集
具体例子sql查询
<%!
//查询课程安排信息
public List getClassPlan(){
StringBuffer sql=new StringBuffer();
sql.append("select tem1.*,tem2.countNum from (select to_char(cp.course_date,'yyyy-MM-dd') as cdate1,")
.append("to_char(cp.start_time,'hh:mi') as sdate,")
.append("to_char(cp.end_time,'hh:mi') as edate,")
.append("cp.name as tname,")
.append("cp.study_way as tsw,")
.append("cp.attach as tatt,")
.append("cp.remark as tre,")
.append("fti.name as tfname,")
.append("fti.department as tdepart,")
.append("fti.job as tjob ")
.append("from s_class_plan cp, s_class_plan_teacher cpt, fl_tea_info fti ")
.append("where cp.id = cpt.plan_id ")
.append("and cpt.teacher_id = fti.id order by cp.course_date,cp.end_time) tem1,")
.append("(select count(*) as countNum, to_char(cp.course_date, 'yyyy-MM-dd') as cdate2")
.append(" from s_class_plan cp,")
.append(" s_class_plan_teacher cpt,")
.append(" fl_tea_info fti")
.append(" where cp.id = cpt.plan_id")
.append(" and cpt.teacher_id = fti.id")
.append(" group by cp.course_date order by cp.course_date) tem2 where tem1.cdate1=tem2.cdate2");
return DaoHelper.getResultSet(sql.toString(),11);
}
%>
页面逻辑代码,运用全局变量的初始化和一次一次循环赋值比较来控制第一行与第二行的td区别
<table width="100%" border="0" align="center" cellpadding="0" cellspacin