Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 21st, 2004, 11:12 AM
jglover jglover is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 85 jglover User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 59 m 52 sec
Reputation Power: 5
Question SQL and ASP Help

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>","&nbsp;") %>
<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 & " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; 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
%>

Reply With Quote
  #2  
Old September 21st, 2004, 11:48 AM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Jun 2004
Posts: 3,002 selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 19 h 40 m 17 sec
Reputation Power: 105
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!

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > SQL and ASP Help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT