SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sum fields that have a count - sql query gives count then grab those counts totals.

    I have a quick and simple page to display a count of some servers. I now need to show a total of the 3 separate counts:

    Code:
    Set objRS2 = conn2.Execute("SELECT count(*) AS pTotal FROM server WHERE ITPOC = 'Projects'")
    Set objRS3 = conn3.Execute("SELECT count(*) AS oTotal FROM server WHERE ITPOC = 'Ops'")
    Set objRS4 = conn4.Execute("SELECT count(*) AS iTotal FROM server WHERE ITPOC = 'Infrastructure'")
    response.Write "<tr>"
    Response.Write "<td class=clsBodyText  align=center>" & "Projects" & "</td>"
    Response.Write "<td class=clsBodyText align=center>" & objRS2.Fields("pTotal") & "</td>"
    response.Write "</tr>"
    response.Write "<tr>"
    Response.Write "<td class=clsBodyText  align=center>" & "Ops" & "</td>"
    Response.Write "<td class=clsBodyText align=center>" & objRS3.Fields("oTotal") & "</td>"
    response.Write "</tr>"
    response.Write "<tr>"
    Response.Write "<td class=clsBodyText  align=center>" & "Infrastructure" & "</td>"
    Response.Write "<td class=clsBodyText align=center>" & objRS4.Fields("iTotal") & "</td>"
    response.Write "</tr>"
    response.Write "<tr>"
    Response.Write "<td class=clsBodyText  align=center>" & "Total" & "</td>"
    Response.Write "<td class=clsBodyText align=center>" & Response.Write ("pTotal" + "oTotal" + "iTotal") & "</td>"  
    response.Write "</tr>"
    Thanks in advance, sure this is easy for a Pro.

  2. #2
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So I was able to get some help and sum my totals:

    Code:
    Set objRS2 = conn2.Execute("SELECT count(*) AS pTotal FROM server WHERE ITPOC = 'Projects'")
    Set objRS3 = conn3.Execute("SELECT count(*) AS oTotal FROM server WHERE ITPOC = 'Ops'")
    Set objRS4 = conn4.Execute("SELECT count(*) AS iTotal FROM server WHERE ITPOC = 'Infrastructure'")
    
    
    gbTotals = (objRS2(0) + objRS3(0) + objRS4(0))
    
    
    response.Write "<tr>"
    Response.Write "<td class=clsBodyText  align=center>" & "Projects" & "</td>"
    Response.Write "<td class=clsBodyText align=center>" & objRS2.Fields("pTotal") & "</td>"
    response.Write "</tr>"
    response.Write "<tr>"
    Response.Write "<td class=clsBodyText  align=center>" & "Ops" & "</td>"
    Response.Write "<td class=clsBodyText align=center>" & objRS3.Fields("oTotal") & "</td>"
    response.Write "</tr>"
    response.Write "<tr>"
    Response.Write "<td class=clsBodyText  align=center>" & "Infrastructure" & "</td>"
    Response.Write "<td class=clsBodyText align=center>" & objRS4.Fields("iTotal") & "</td>"
    response.Write "</tr>"
    response.Write "<tr>"
    Response.Write "<td class=clsBodyText  align=center>" & "Total" & "</td>"
    Response.Write "<td class=clsBodyText align=center>" & gbTotals & "</td>"
    response.Write "</tr>"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •