|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have a database being updated by a text file every ten minutes, so in the code that is why the column names are messed up. My problem is I get all the sums, and counts all working. What I need to do is at the end of it have a sum for for all the columns returned, i.e. col002, I need all the sums in that column added up for a total at the bottom. The following code works but when I try to do column totals I can't get it to work, any help would be greatly appreciated.
<%@ LANGUAGE="VBSCRIPT" %> <% Option Explicit%> <% If Session("loggedin") = "" Then Response.redirect ("../../../login.asp") End If %> <!--#include file="inc-dbconnection.asp"--> <% Dim strData, datebox, datebox2 datebox=request.form("datebox") datebox2=request.form("datebox2") 'Create a recordset Dim rs, hook Set rs = Server.CreateObject("ADODB.Recordset") rs.Open "SELECT (Col002),COUNT (Col008), SUM (Col004),SUM (Col005),SUM (Col006),SUM (Col007),SUM (Col008),COUNT(Col010), COUNT (Col011), SUM (Col009), AVG (Col009) FROM SQL1 WHERE Col014 BETWEEN '" & datebox & "' AND '" & datebox2 & "'GROUP BY Col002 ORDER BY Col002",objConn 'Store our one big string Dim strTable strTable = rs.GetString(,,"</td><td>","</td></tr><tr><td>"," ") %> <HTML> <BODY> <img src="pinesmall1.jpg"> <%Response.Write("<H1 align=center>Hot Scale Summary</H1><BR><H2 align=center>Lot Summary</H2>")%> <%Response.Write("<p align=center> From: " & datebox & " To: " & datebox2 & "")%> <% Response.Write("<table align=center border=1 cellspacing=2 bgcolor=LightSteelBlue>") Response.Write("<B><td><B>Lot</td><td><B>Hogs</td><td><B>Hams</td><td><B>Loins</td><td><B>Butts</td><td><B>Picnic</td><td><B>Bellys</td><td><B>Hooks</td><td><B>Shrink</td><td><B>Total Weight</td><td><B>Average Weight</td><td></tr><tr><td>") Response.Write(strTable) %> </BODY> </HTML> <% 'Cleanup! rs.Close Set rs = Nothing objConn.Close Set objConn = Nothing %> |
|
#2
|
||||
|
||||
|
Please don't post across multiple forums - it gets a bit confusing:
http://forums.aspfree.com/t37427/s.html
__________________
selwonk If I've posted some code above, you might think it looks a bit simplistic. It might be. I'd rather people tried the next step themselves rather than getting a full solution on a plate. That way they learn more! |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > SQL and ASP Help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|