我要做一个纳税人数的统计,按照地区(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

解决方案 »

  1.   

    做页面显示的话,你需要写程序去实现,首先你要知道你用的数据库符合哪种标准,是jdbc,还是odbc等等,然后把结果集放在ResultSet对象中,
    循环往table里的tr和td相应的赋值就可以了,可以采用页面循环,也可以使用Javascript,也可以使用struts框架中的自定义标签。
      

  2.   

    查询出来的数据是ResultSet,然后把ResultSet里面的数据存到List里面,具体怎么存去查看ResultSet的API。之后把List返回给页面,迭代显示,js,java,struts标签,jstl标签都可以实现的。
      

  3.   

    最简单放到 ArrayList 中循环不就可以了
      

  4.   

    楼上都没理解到我的意思,我是说在table里面有2个标题栏,一个横行状态(isinuse)一个纵行地区(deptid)。在表的中间部分根据横行和纵行,对应的显示count的值。我不知道怎么样让它对应起来。
      

  5.   

    明确table的数据接口 得到数据如ResultSet再导入啊
      

  6.   

    这种例子太多了 截取一段 JpetStore 的代码给你参考一下
    这段代码就是以 Product ID | Name 为列循环显示数据的 用的是 Jstl 把数据存到 productList.pageList 这个 ArrayList 里用 foreach 循环<table align="center" bgcolor="#008800" border="0" cellspacing="2" cellpadding="3">
      <tr bgcolor="#CCCCCC">  <td>&nbsp;</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>&lt;&lt; Prev</B></font></a>
      </c:if>
      <c:if test="${!productList.lastPage}">
        <a href="?page=next"><font color="white"><B>Next &gt;&gt;</B></font></a>
      </c:if>
      </td>
      </tr></table>