<%@ Language=VBScript %> <% Set conn = Server.CreateObject("ADODB.Connection") conn.Open(MM_cotec_STRING) sql = "Select Distinct company From signData Order By company" 'DISTINCT 不重複的結果 Set rsCompany = conn.Execute(sql) totalPerson = 0 totalSum = 0 %> 費用統計 <% Do While Not rsCompany.Eof '同一個公司跑迴圈 sql = "SELECT keyman FROM signData Where company = '" & rsCompany("company") & "' GROUP BY keyman" Set rskeyman = conn.Execute(sql) sql = "SELECT * From signData Where keyman = '" & rskeyman("keyman") & "'" Set rs = conn.Execute(sql) counter = 0 '總報名人數 subTotal = 0 '總費用 Do While Not rskeyman.Eof %>
公司全銜\統號 聯絡人 聯絡地址\郵遞區號 電 話 傳 真
<%=rs("company")%>(<%=rs("no")%>) <%=rs("keyman")%> <%=rs("post")%> <%=rs("add")%> <%=rs("tel")%> <%=rs("fax")%>
<% counter = 0 '總報名人數 subTotal = 0 '總費用 sql = "Select * From signData Where company = '" & rsCompany("company") & "' Order By company,keyman" 'sql = "SELECT signData.company, signData.keyman, signData.add, signData.post, signData.tel, signData.fax,signData.[sum] FROM signData Where company = '" & rsCompany("company") & "' GROUP BY signData.company, signData.keyman, signData.add, signData.post, signData.tel, signData.fax;" Set rs = conn.Execute(sql) Do While Not rs.Eof %> <% counter = counter + 1 subTotal = subTotal + rs("sum") totalPerson = totalPerson + 1 totalSum = totalSum + rs("sum") %> <% rs.MoveNext Loop %> <% rskeyman.MoveNext Loop %>
參加人姓名 職稱 參加場次 身分 費用
<% If IsNull(rs("name")) Then Response.Write("") Else Response.Write(rs("name")) End If%> <% If IsNull(rs("title")) Then Response.Write("") Else Response.Write(rs("title")) End If%> <% If IsNull(rs("play")) Then Response.Write("") Else Response.Write(rs("play")) End If%> <% If IsNull(rs("etype")) Then Response.Write("") Else Response.Write(rs("etype")) End If%> <% Response.Write(rs("sum"))%>
目前總計:<%=counter%> 人參加報名,總計費用:<%=subTotal%> 元。

<% rsCompany.MoveNext Loop %>
目前所有總計:<%=totalPerson%> 人參加報名,總計費用:<%=totalSum%> 元。