Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need to display the results from a record set

Status
Not open for further replies.

jcook32

Programmer
Jun 11, 2003
20
US
I have a SQL statement that returns some data say 1000 rows. Each row has a Dept in common. Each dept has Groups within it. Say Dept1 has 3 Sub Groups. Each sub group may have any number of records for the question's sake lets say group one has 500 rows and Group 2 has 300 rows and group 3 has 200 rows. On my asp page I need to show 1 record for each subgroup and keep a running total of 4 other columns. I need all the numbers from each column added up for say group 1's 500 records.
this is an example of my table on my page:
Government Services Group 0 3356 2394 0 0 5750
Health Care Group 3125.1 0 0 0 0 6250.2
Intellectual Property Group 47918.4 0 0 0 0 95836.8
Department Total:
The numbers being my total of each column within each sub group(ie. health care group)

Please Help!!!!

Thanks
jcook32




 
you can jsut use a SUM() function int he SQL statement and execute it. what exactely do you need help with .
The entire process, the connection, or execution

1H 1K 10 3D 3F 3E 3K 38 3J 10 1T 10 3G 3L 3I 35 10 35 3O 33 35 3C 3C 35 3E 33 35

onpnt2.gif
 
this is my sql statement:
SQLstr="SELECT tkinit,tkfirst,tklast,tkloc,ldesc,tkdept,head1,tksect,tsectdes,mclient,clname1,"
SQLstr=SQLstr& " right(mmatter,5) as matter,mdesc1,"
SQLstr=SQLstr& " (arf1 + arc1 + aro1 + ari1) as one,"
SQLstr=SQLstr& " (arf2 + arc2 + aro2 + ari2) as two,"
SQLstr=SQLstr& " (arf3 + arc3 + aro3 + ari3) as three,"
SQLstr=SQLstr& " (arf4 + arc4 + aro4 + ari4) as four,"
SQLstr=SQLstr& " (arf5 + arc5+ aro5 + ari5 + arf6 + arc6 + aro6 + ari6) as five,"
SQLstr=SQLstr& " (arf1 + arc1 + aro1 + ari1) + (arf2 + arc2 + aro2 + ari2) + (arf3 + arc3 + aro3 + ari3) + (arf4 + arc4 + aro4 + ari4) + (arf5 + arc5+ aro5 + ari5 + arf6 + arc6 + aro6 + ari6) as ttl"
SQLstr=SQLstr& " FROM matter, df_dwmatter, client, timekeep, tsection, deptlab, location"
SQLstr=SQLstr& " WHERE (matter.mclient = client.clnum) and (timekeep.tkinit = matter.mbillaty) and"
SQLstr=SQLstr& " (mmatter = matter) and (tsection.tsection = tksect) and (deptlab.delcode = timekeep.tkdept) and"
SQLstr=SQLstr& " (timekeep.tkloc = location.locode) and"
SQLstr=SQLstr& " (matter.mmatter in (SELECT udf.udjoin FROM udf WHERE (udf.udfindex = 55) AND (udf.udvalue IS NULL OR udf.udvalue = 'U')) OR"
SQLstr=SQLstr& " matter.mclient in (SELECT udf.udjoin FROM udf WHERE (udf.udfindex = 197) AND (udf.udvalue IS NULL OR udf.udvalue = 'U'))) and"
SQLstr=SQLstr& " ((arf1 + arc1 + aro1 + ari1 +arf2 + arc2 + aro2 + ari2 + arf3 + arc3 + aro3 + ari3 + arf4 + arc4 + aro4 + ari4 + arf5 + arc5+ aro5 + ari5 + arf6 + arc6 + aro6 + ari6) > 2500) AND"
SQLstr=SQLstr& " df_dwmatter.pe = " & rs2("pe") & " and"
SQLstr=SQLstr& " tkdept ='" & dept & "' AND"
SQLstr=SQLstr& &quot; tkloc <>'50' AND tkloc<>'51'&quot;
SQLstr=SQLstr& &quot; ORDER BY tsectdes,mclient&quot;
response.Write SQLstr
set rs=dbConn.execute(SQLstr)

and this is my loop to right out the html
do while not rs.eof
strDispName=rs(&quot;tsectdes&quot;)
locDesc= rs(&quot;ldesc&quot;)
dept=rs(&quot;head1&quot;)

intTotPts1=intTotPts1 + rs(&quot;one&quot;)
intTotPts2=intTotPts2 + rs(&quot;two&quot;)
intTotPts3=intTotPts3 + rs(&quot;three&quot;)
intTotPts4=intTotPts4 + rs(&quot;four&quot;)
intTotPts5=intTotPts5 + rs(&quot;five&quot;)
intTotPtsttl=intTotPtsttl + rs(&quot;ttl&quot;)

if strFullName=strDispName then
else
response.Write intTotPts1 & intTotPts2 & intTotPts3 & intTotPts4 & intTotPts5
response.Write &quot;<BR>&quot;
if intTotPts1 > 0 or intTotPts2 >0 or intTotPts3 >0 or intTotPts4 >0 or intTotPts5 >0 or intTotPtsttl > 0 then
response.write &quot;<tr bgcolor=&quot; & rspaleyellow & &quot;><td class=home2textB>&quot; & rs(&quot;tsectdes&quot;) & &quot;</td>&quot;
response.write &quot;<td class=home2text>&quot; & formatcurrency(intTotPts1,2)& &quot;</td>&quot;
response.write &quot;<td class=home2text>&quot; & formatcurrency(intTotPts2,2) & &quot;</td>&quot;
response.write &quot;<td class=home2text>&quot; & formatcurrency(intTotPts3,2) & &quot;</td>&quot;
response.write &quot;<td class=home2text>&quot; & formatcurrency(intTotPts4,2) & &quot;</td>&quot;
response.write &quot;<td class=home2text>&quot; & formatcurrency(intTotPts5,2) & &quot;</td>&quot;
response.write &quot;<td class=home2text>&quot; & formatcurrency(intTotPtsttl,2) & &quot;</td>&quot;
response.write &quot;</tr>&quot;
end if
intTotPts1=0
intTotPts2=0
intTotPts3=0
intTotPts4=0
intTotPts5=0
intTotPtsttl=0
strFullName=strDispName
end if

'if Not strTLoc=rs(&quot;tkloc&quot;) then
' if intFirst=1 then
' response.write &quot;<tr><td height=40>&nbsp;</td></tr>&quot;
' end if
' intSpace=0
' response.write &quot;<Table align=center width=10% cellspacing=0 cellpadding=3><tr><td class=home2textb align=&quot;&quot;center&quot;&quot; nowrap>&quot; & locDesc & &quot;</td></tr></table>&quot;
'end if

'if Not strFullName=strDispName then
' response.write &quot;<tr><td class=home2textb colspan=7>Total</td></tr>&quot;
'end if
'if intQF=1 then
' if rs(&quot;one&quot;) > 0 and rs(&quot;two&quot;)>0 and rs(&quot;three&quot;)>0 and rs(&quot;four&quot;)>0 and rs(&quot;five&quot;)>0 and rs(&quot;ttl&quot;)>0 then
' intDisp=0
' else
intDisp=1
' end if
'end if

if intDisp=0 then
if Not strFullName=strDispName then
response.write &quot;<table style=&quot;&quot;border:solid &quot; & tableborder & &quot; 1px&quot;&quot; align=&quot;&quot;center&quot;&quot; width=&quot;&quot;95%&quot;&quot;>&quot;
response.write &quot;<tr class=tablehead2><td class=home2textb colspan=7>&quot; & dept & &quot;</td>&quot;
response.write &quot;</tr>&quot;
response.write &quot;<tr class=tablehead>&quot;
response.write &quot;<th width=&quot;&quot;25%&quot;&quot;>Matter Resp Attorney/Matter</th>&quot;
response.write &quot;<th>30 Days of Less</th>&quot;
response.write &quot;<th>31-60 Days</th>&quot;
response.write &quot;<th>61-90 Days</th>&quot;
response.write &quot;<th>91-120 Days</th>&quot;
response.write &quot;<th>120 Days of More</th>&quot;
response.write &quot;<th>Net Outstanding</th>&quot;
response.write &quot;</tr>&quot;
end if
if v=1 then
bgcolor=rsgreyll
v=0
else
bgcolor=&quot;#ffffff&quot;
v=1
end if

if Not strFullName=strDispName then
response.write &quot;<tr bgcolor=&quot; & bgcolor & &quot; class=home2text valign=top>&quot;
response.write &quot;<td>&quot; & rs(&quot;tsectdes&quot;) & &quot;</td>&quot;
response.write &quot;<td>&quot; & formatcurrency(rs(&quot;one&quot;),2) & &quot;</td>&quot;
response.write &quot;<td>&quot; & formatcurrency(rs(&quot;two&quot;),2) & &quot;</td>&quot;
response.write &quot;<td>&quot; & formatcurrency(rs(&quot;three&quot;),2) & &quot;</td>&quot;
response.write &quot;<td>&quot; & formatcurrency(rs(&quot;four&quot;),2) & &quot;</td>&quot;
response.write &quot;<td>&quot; & formatcurrency(rs(&quot;five&quot;),2) & &quot;</td>&quot;
response.write &quot;<td>&quot; & formatcurrency(rs(&quot;ttl&quot;),2) & &quot;</td>&quot;
response.write &quot;</tr>&quot;
end if
'running totals
end if

intSpace=1
intFirst=1
strTLoc=rs(&quot;tkloc&quot;)
'strFullName=strDispName

rs.movenext
loop
I am able to right out the subgroups 1 time(if there are three there will be there rows. The problem i cannot get the running totals for each of the sub group to adde up right
 
the data returned from the sql statement looks like this
grpname under 30 days $$
xxx 200
xxx 255
xxx 666
xxx 888
xxx 444

yyy 555
yyy 343
yyy 656
yyy 878
yyy 557

zzz 3434
zzz 454
zzz 322
zzz 0909
zzz 7878


i hope this helps some more
i need the totals of xxx,yyy,zzzz


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top