Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8207279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:56:50+00:00 2026-06-07T08:56:50+00:00

Struggling to display output of RS as a horizontal table. I’ve a RS based

  • 0

Struggling to display output of RS as a horizontal table.

I’ve a RS based on following SQL

SQL = "SELECT INTRAY.TEAM, Count(INTRAY.DOC_GUID) AS NumDocs " & _
"FROM INTRAY INNER JOIN DOCUMENT ON INTRAY.DOC_GUID = DOCUMENT.GUID " & _
"WHERE DOCUMENT.DOC_TYPE = 'PNEW' " & _
"AND DOCUMENT.DATE_RECEIVED > '"& Year(FromDate) &"-"& Month(FromDate) &"-"& Day(FromDate) &"' " & _
"GROUP BY INTRAY.TEAM, INTRAY.MAIL_STATUS, INTRAY.FILE_SYSTEM " & _
"HAVING INTRAY.MAIL_STATUS = 'NT' AND INTRAY.FILE_SYSTEM ='B' " & _
"ORDER BY INTRAY.TEAM ;"

I display results in a normal table, as below

<table border=1>
    <tr>
        <th>Team</th>
        <th>Records</th>
    </tr>
<%Do While Not RS.EOF %>
    <tr>
        <td><%=RS("TEAM")%></td>
        <td><%=RS("NumDocs")%></td>
    </tr>
<% RS.MoveNext
Loop%>
</table>

The resutls display normally in a vertial table. 10 records are returned, sorted by Team. OPS1, OPS10, OPS2 etc.

Note that 10 comes after 1 due to alpha sorting, don’t know how to amend this.

There are only ever 10 teams that could be in the output, but sometimes not all will have a result, so the table could only return say, 2 or 3 teams.

I want to create a table which has hard coded column headings for each possible team (1 – 10), and then the next row being the output values for NumDocs

Team 1 10 2 3 4 5 6 7 8 9

Results 8 4 7 17 4 87 20 19 1 7

So, I then close the recordset, and re-open it;

<%RS.Close%>
<br>

<%
RS.cursortype=adOpenKeyset
RS.Open SQL, IConn, 3, 3
RS.MoveFirst
%>

And write the table;

<table border=1>
<th>Report</th>
<th>OPS1</th>
<th>OPS10</th>
<th>OPS2</th>
<th>OPS3</th>
<th>OPS4</th>
<th>OPS5</th>
<th>OPS6</th>
<th>OPS7</th>
<th>OPS8</th>
<th>OPS9</th>
<tr>
<td>Untouched New Records (total)</td>
<td>
<%If RS("Team") = "OPS1" Then %>
<% Response.Write(RS("NumDocs")) 
Else Response.Write("Not OPS1")
RS.MoveNext
End If %>
</td>
<td>
<%If RS("Team") = "OPS10" Then %>
<% Response.Write(RS("NumDocs")) 
Else Response.Write("Not OPS1")
RS.MoveNext
End If %>
</td>
<td>
<%If RS("Team") = "OPS2" Then %>
<% Response.Write(RS("NumDocs")) 
Else Response.Write("Not OPS2")
RS.MoveNext
End If %>
</td>
<td>
<%If RS("Team") = "OPS3" Then %>
<% Response.Write(RS("NumDocs")) 
Else Response.Write("Not OPS3")
RS.MoveNext
End If %>
</td>
<td>
<%If RS("Team") = "OPS4" Then %>
<% Response.Write(RS("NumDocs")) 
Else Response.Write("Not OPS4")
RS.MoveNext
End If %>
</td>
<td>
<%If RS("Team") = "OPS5" Then %>
<% Response.Write(RS("NumDocs")) 
Else Response.Write("Not OPS5")
RS.MoveNext
End If %>
</td>
<td>
<%If RS("Team") = "OPS6" Then %>
<% Response.Write(RS("NumDocs")) 
Else Response.Write("Not OPS6")
RS.MoveNext
End If %>
</td>
<td>
<%If RS("Team") = "OPS7 " Then %>
<% Response.Write(RS("NumDocs")) 
Else Response.Write("Not OPS7")
RS.MoveNext
End If %>
</td>
<td>
<%If RS("Team") = "OPS8" Then %>
<% Response.Write(RS("NumDocs")) 
Else Response.Write("Not OPS8")
RS.MoveNext
End If %>
</td>
<td>
<%If RS("Team") = "OPS9" Then %>
<% Response.Write(RS("NumDocs")) 
Else Response.Write("Not OPS9")
RS.MoveNext
End If %>
</td>
</tr>
</table>

It won’t work, all I get it ‘Not OPSx” in the output.

The If Test is not working.

If I amend each cell to

<% Response.Write(RS("NumDocs")) 
RS.MoveNext  %>

Then it will write the value, but I need to test for the value of TEAM in that row in the RS, and if I amend this to

<% If RS("Team") = "OPS1" Then
Response.Write(RS("NumDocs")) 
End If
RS.MoveNext  %>

It won’t work and writes nothing.

Any ideas why mty IF is not working? When I write the values of TEAM, they appear to be OK and don’t have trailing spaces. The SQL Server won’t accept a TRIM function

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:56:52+00:00Added an answer on June 7, 2026 at 8:56 am

    SQL Server may not accept TRIM, but it should accept RTRIM and LTRIM, such as:

    SELECT INTRAY. RTRIM(TEAM), Count(INTRAY.DOC_GUID) AS NumDocs 
    

    If you don’t want to trim in your SQL statement (which I suggest you do), you can always try trimming your IF statements like this:

    <%If Trim(RS("Team")) = "OPS1" Then %>  
    

    If you do <% Response.Write "!" & RS("Team") & "!") %> of your data right now, I suspect you’ll see something like:

    !OPS1 !
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to display a specific tumblr post, based on tags. Struggling with: 1.
I'm struggling to display a watermark (so called placeholder) on my MVC3 form inputs.
struggling a bit to get the following to work : I'm trying to merge
I'm struggling to compare two php variables to display or not display some text
I am struggling to get my interior background image to display in IE, works
I'm struggling getting a certain column within my DataGridView to display things right. It
I have the following setup... Table: properties p_id [pk] p_propname o_id_owners [fk] Table: owners
I am struggling in my attempts to programmatically display a form to display in
I am struggling to get the Telerik MVC Grid to display number formatted according
So I've been struggling on a rather weird problem. I've tried everything from display:inline-block

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.