我要做一个纳税人数的统计,按照地区(deptid)和状态(isinuse)分开。显示在一个table里,地区纵向显示,状态横向显示。我的sql如下,我想请教一下,如何才能把查询出来的数据显示在table里呢?
select u.deptid CODE, u.isinuse isinuse, count(distinct taxpayernum) COUNT
from ds_nsrstate n, ds_user u
where u.taxpayernum = n.tpayer_id
and u.isinuse = n.state
and areaid = '070000'
and areaid <> '000000'
and isinuse not in ('1', '5', '0')
and n.time <= to_date('2007-11-21', 'yyyy-mm-dd')
group by rollup(u.deptid, u.isinuse)
order by u.deptid, u.isinuse
select u.deptid CODE, u.isinuse isinuse, count(distinct taxpayernum) COUNT
from ds_nsrstate n, ds_user u
where u.taxpayernum = n.tpayer_id
and u.isinuse = n.state
and areaid = '070000'
and areaid <> '000000'
and isinuse not in ('1', '5', '0')
and n.time <= to_date('2007-11-21', 'yyyy-mm-dd')
group by rollup(u.deptid, u.isinuse)
order by u.deptid, u.isinuse
循环往table里的tr和td相应的赋值就可以了,可以采用页面循环,也可以使用Javascript,也可以使用struts框架中的自定义标签。
这段代码就是以 Product ID | Name 为列循环显示数据的 用的是 Jstl 把数据存到 productList.pageList 这个 ArrayList 里用 foreach 循环<table align="center" bgcolor="#008800" border="0" cellspacing="2" cellpadding="3">
<tr bgcolor="#CCCCCC"> <td> </td> <td><b>Product ID</b></td> <td><b>Name</b></td> </tr>
<c:forEach var="product" items="${productList.pageList}">
<tr bgcolor="#FFFF88">
<td><a href="<c:url value="/shop/viewProduct.do"><c:param name="productId" value="${product.productId}"/></c:url>">
<c:out value="${product.description}" escapeXml="false"/></a></td>
<td><b><a href="<c:url value="/shop/viewProduct.do"><c:param name="productId" value="${product.productId}"/></c:url>">
<font color="BLACK"><c:out value="${product.productId}"/></font>
</a></b></td>
<td><c:out value="${product.name}"/></td>
</tr>
</c:forEach>
<tr>
<td>
<c:if test="${!productList.firstPage}">
<a href="?page=previous"><font color="white"><B><< Prev</B></font></a>
</c:if>
<c:if test="${!productList.lastPage}">
<a href="?page=next"><font color="white"><B>Next >></B></font></a>
</c:if>
</td>
</tr></table>