DAO:
public List<Object[]> findbyContSQL()
{
String sql="SELECT count(*),count(case nationality when 'CN' then id end) as countCN,"
+" count(case nationality when 'CN' then case substring(cardno,0,3) when '110' then id end end) as countBeiJing,"
+" count(case nationality when 'CN' then case substring(cardno,0,3) when '110' then null else id end end) as countWaiSheng,"
+" count(case nationality when 'CN' then null else id end) as countJingwai"
+" FROM dbo.ES_USER";
return getSession().createSQLQuery(sql).list();
}
SERVICE:
public List<Object[]> findbyContSQL()
{
return esUserDao.findbyContSQL();
}
ACTION:
protected static final String JOB_SHOW="/WEB-INF/pages/es/EsUser/psShow.jsp";
public String jobTable(){
try {
List<Object[]> cont=esUserManager.findbyContSQL();
getRequest().setAttribute("obj", obj);
} catch (Exception e) {
e.printStackTrace();
}
return JOB_SHOW;
}
JSP:
<td rowspan=2 height=38 class=xl6523224 style='border-bottom:1.0pt solid black;
height:28.5pt;border-top:none'>${obj[0]}</td>
本文介绍了一个使用SQL进行复杂条件下的统计分析案例,包括按国籍、省份等维度进行计数,并展示了DAO层、Service层及Action层的具体实现方式。
276

被折叠的 条评论
为什么被折叠?



