SQL,出数据问题,大侠们进来帮忙看一下。怎么出数据。 代码:
<%
sql="select BdName AS KK from QJDiaoBanBiao WHERE (Zb <> 0) AND (ZT = 0) AND (ZhangTai = 1) AND (ZT1 >= 1) group by BdName"
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
%>
<table width="400" border="1">
<tr>
<td>姓名</td>
<td>1月</td>
<td>2月</td>
<td>3月</td>
<td>4月</td>
<td>....12月</td>
<td>....汇总</td>
</tr>
<%
do while not rs.eof
%>
<tr>
<td><font color="#990000" size="3"><strong><%=rs("KK")%></strong></font></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
select
bdname,
sum(case when month(datetime1)=1 then Type1='进' then QJTS else 0 end) as '一月进',
sum(case when month(datetime1)=1 then Type1='出' then QJTS else 0 end) as '一月出',
... --剩下11个月自己写
from
tb
group by
bdname
------解决方案--------------------
select
bdname,
sum(case when month(datetime1)=1 then Type1='进' then QJTS else 0 end) as '一月进',
sum(case when month(datetime1)=1 then Type1='出' then QJTS else 0 end) as '一月出',
... --剩下11个月自己写
,sum(数量) as 汇总
from
tb
group by
bdname